+ Reply to Thread
Results 1 to 6 of 6

copy contents of last row to a specific cell in another worksheet

Hybrid View

  1. #1
    Registered User
    Join Date
    01-29-2013
    Location
    Bristol, England
    MS-Off Ver
    Excel 365
    Posts
    40

    copy contents of last row to a specific cell in another worksheet

    I have a datasheet (ProjectData) that collects data from a userform. Each time the userform is used it puts the data into the next empty row of my datasheet.

    However, I then want to link the data from the last used row in the datasheet to specific cells in other worksheets (which make up the report I am trying to create).

    Normally I would just copy from the datasheet i.e. A5 and then paste (link) into the specific cells of other worksheets i.e.

    =ProjectData!$A$5

    BUT instead of row 5 of column A in the worksheet ProjectData, I want it to automatically link whatever was the last row of column A populated in my datasheet ProjectData

    It is driving me crazy because it has to be something really easy.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: copy contents of last row to a specific cell in another worksheet

    usually you would do something like this:
    Sheets("Sheet1").Range("A1")=Cells(Rows.Count,1).End(XlUp)
    it will put in your Sheet1 cell A1 the value of the last row in column A.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    01-29-2013
    Location
    Bristol, England
    MS-Off Ver
    Excel 365
    Posts
    40

    Re: copy contents of last row to a specific cell in another worksheet

    The problem is I need the data of the last row of columns in sheet 1 to always go into a fixed cell of sheet 2

    I.e. Last row of column A in sheet 1 to go into cell B56 of sheet2, last row of column B in sheet1 to go into cell Z5 of sheet13 etc

    I have 107 columns in sheet1 to collate data from my user form and 15 other sheets with specific cells to be populated from sheet1 that make up the report
    Last edited by Angelique Cassam; 06-21-2017 at 10:42 AM. Reason: I am trying to add the example I created but cannot do this!

  4. #4
    Registered User
    Join Date
    01-29-2013
    Location
    Bristol, England
    MS-Off Ver
    Excel 365
    Posts
    40

    Re: copy contents of last row to a specific cell in another worksheet

    Here is an example. The userform (formMeLoc) puts the entries into the worksheet called Data always populating the next row available.

    Then from worksheet called Data I want to put the last row entry of:

    column A (Name) into Sheet 2 cell C6
    column B (Age) into Sheet 2 cell C8
    column C (Phone No) into Sheet 3 cell G18

    I would like this to be automatically done or I am happy to have a button with vba to populate sheet 2 and 3 once the userform has been closed.

    Each time the userform is used it will then create the report (which consists of sheet2 and sheet3).

    I hope that makes more sense.
    Attached Files Attached Files
    Last edited by Angelique Cassam; 06-21-2017 at 10:54 AM. Reason: I was not making myself very clear the last time

  5. #5
    Registered User
    Join Date
    01-29-2013
    Location
    Bristol, England
    MS-Off Ver
    Excel 365
    Posts
    40

    Re: copy contents of last row to a specific cell in another worksheet

    Thank you so much this has worked beautifully.

  6. #6
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: copy contents of last row to a specific cell in another worksheet

    how about this modification of your cmdAdd_Click() macro:
    Private Sub cmdAdd_Click()
    
    Dim iRow As Long
    Dim ws As Worksheet
    Set ws = Worksheets("Data")
    
    iRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
    SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
    
    If Trim(Me.txtName.Value) = "" Then
    Me.txtName.SetFocus
    MsgBox "Please enter your name"
    Exit Sub
    
    End If
    
    With ws
    
    .Cells(iRow, 1).Value = Me.txtName.Value
    .Cells(iRow, 2).Value = Me.txtAge.Value
    .Cells(iRow, 3).Value = Me.txtPhone.Value
    'Here you place your data in your specific sheets and cells
    Sheets("Sheet2").Range("C6") = Me.txtName.Value
    Sheets("Sheet2").Range("C8") = Me.txtAge.Value
    Sheets("Sheet3").Range("G18") = Me.txtPhone.Value
    End With
    
    Me.txtName.Value = ""
    Me.txtAge.Value = ""
    Me.txtPhone.Value = ""
    
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 3
    Last Post: 08-21-2015, 06:03 PM
  2. Copy / paste contents of specific cell on double-click
    By conger in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 05-22-2015, 08:29 AM
  3. Replies: 0
    Last Post: 05-21-2015, 09:19 AM
  4. Automatically Copy contents of cell to another worksheet?
    By stokie1976 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-22-2012, 07:57 AM
  5. Creating, copying and renaming new worksheet based on specific cell contents
    By johnejo in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-26-2012, 01:16 PM
  6. Automatically Copy contents of cell to another worksheet?
    By pafranklin in forum Excel General
    Replies: 4
    Last Post: 01-26-2008, 08:34 AM
  7. Replies: 1
    Last Post: 01-21-2006, 05:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1