Help with Copy Function

Orphevs

New Member
Joined
Dec 7, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Hello. Would somebody be able to help please. I have a sheet in which the first 3 rows are headers and the data starts in A4. A variable number of rows starting in A4 will be completed. I would like to copy only the completed rows to a second sheet. When I run the code copied below, it is copying from the third row to the last completed row. Any ideas? Apologies, I am very new to this.

Thanks for the help!

VBA Code:
Private Sub CommandButton1_Click()
    Unload Me

'Define copy selection as 4th row to last completed row, columns A to AD (30)
    LastRow = ActiveSheet.Cells(ActiveSheet.Rows.Count, 30).End(xlUp).Row

'Load completed cases to the Log sheet on clicking "Yes"
    Sheets("Today's List").Range("A4", ActiveSheet.Cells(LastRow, 30)).Copy
    Sheets("Log").Cells(Rows.Count, "A").End(xlUp).Offset(1). _
        PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, _
        SkipBlanks:=False, Transpose:=False
    Application.CutCopyMode = False
   
'Clear the list
    ActiveWorkbook.Worksheets("Today's List").Range("B2").ClearContents
    ActiveWorkbook.Worksheets("Today's List").Range("A4:AD500").ClearContents
   
'Pop up response
    response = MsgBox("Cases Uploaded")

End Sub
 
Last edited by a moderator:

Some videos you may like

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Orphevs

New Member
Joined
Dec 7, 2020
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Not to worry, Google has solved it for me! Thanks anyway
 

Watch MrExcel Video

Forum statistics

Threads
1,127,567
Messages
5,625,550
Members
416,116
Latest member
Joemamasuka

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top