PDA

View Full Version : Solved: Help! Next empty cell question



Pizzafiend
12-21-2005, 01:36 PM
Why does this code start the paste at r1c22 in the destination sheet?

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

Norie
12-21-2005, 01:41 PM
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.

LastRow = Range("A65536").End(xlUp).Row

Pizzafiend
12-21-2005, 01:53 PM
I am new at VBA so bare with me.


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

austenr
12-21-2005, 02:14 PM
This worked for me:

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

Zack Barresse
12-21-2005, 02:16 PM
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

.. should do it.

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

austenr
12-21-2005, 02:43 PM
:rotlaugh: Too funny!!

Pizzafiend
12-21-2005, 07:12 PM
Thanks, that did it.
http://vbaexpress.com/forum/images/smilies/beerchug.gif