Consulting

Results 1 to 7 of 7

Thread: Solved: Help! Next empty cell question

  1. #1

    Solved: Help! Next empty cell question

    Why does this code start the paste at r1c22 in the destination sheet?

    [VBA]Private Sub cmdTransferEmpNum_Click()
    Dim LastRow As Long
    LastRow = Range("A65536").End(xlUp).Row
    Worksheets("YTD").Range("A8").Copy _
    Destination:=Worksheets("Data Gathering II").Cells(LastRow + 1, 1)
    End Sub[/VBA]

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    Which sheet are you trying to get the last/next row for?

    Which sheet is active when you run the code?

    Since this line doesn't reference any sheet VBA will use whatever sheet is active.
    [vba]
    LastRow = Range("A65536").End(xlUp).Row
    [/vba]

  3. #3
    I am new at VBA so bare with me.


    I am looking for the last row in the Data Gathering II sheet.

  4. #4
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    This worked for me:

    [VBA] Private Sub cmdTransferEmpNum_Click()
    Dim LastRow As Long
    LastRow = Worksheets("Data Gathering II").Range("A65536").End(xlUp).Row
    Worksheets("YTD").Range("A8").Copy _
    Destination:=Worksheets("Data Gathering II").Cells(LastRow + 1, 1)
    End Sub [/VBA]
    Peace of mind is found in some of the strangest places.

  5. #5
    Site Admin
    Urban Myth
    VBAX Guru
    Joined
    May 2004
    Location
    Oregon, United States
    Posts
    4,940
    Location
    [VBA]Private Sub cmdTransferEmpNum_Click()
    Dim LastRow As Long
    LastRow = Sheets("Data Gathering II").Range("A65536").End(xlUp).Row
    Worksheets("YTD").Range("A8").Copy _
    Destination:=Worksheets("Data Gathering II").Cells(LastRow + 1, 1)
    End Sub[/VBA]

    .. should do it.

    Edit: Whoops! It's what I get for taking too long to hit the reply button. LOL!

  6. #6
    Moderator VBAX Master austenr's Avatar
    Joined
    Sep 2004
    Location
    Maine
    Posts
    2,033
    Location
    Too funny!!
    Peace of mind is found in some of the strangest places.

  7. #7
    Thanks, that did it.

Posting Permissions

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