View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Auric__ Auric__ is offline
external usenet poster
 
Posts: 538
Default VBA copy and paste data

Paul Mullan wrote:

I have a spreadsheet that I am using as a database and a userform that I
am using as the entry portal for the data being entered

I am trying to add some VBA to the userform that will copy data in
columns A-C, but only from the last row of entered data. The VBA will
run when button CommandButton1 is pressed.


This copies (to the clipboard) from the bottom row that has any data in any
of those 3 columns:

workRow = 0
lastRow = Cells.SpecialCells(xlCellTypeLastCell).Row
For L0 = 1 To 3
If Len(Cells(lastRow, L0).Value) < 1 Then
r1 = Cells(lastRow, L0).End(xlUp).Row
Else
r1 = lastRow
End If
If workRow < r1 Then workRow = r1
Next
Range("A" & workRow & ":C" & workRow).Copy

--
- They're brainwashing you, watch out.
- but i'm hungry
- That's what they want you to think.