Macros, Objects, and Pasting... Help!!!

blooka241

New Member
Joined
Jun 26, 2008
Messages
3
I'm trying to write a macro that will locate and copy the last row of information in a worksheet and paste it into another worksheet. This is what I've written so far:

Dim counter As Integer
For counter = 1 To 25
i = counter - 1
If Cells(1, counter) < 1 Then Range("Ai:Fi").Select
Selection.Copy

Worksheets("Sheet2").Activate
Worksheets("Sheet2").Range("K2:P2").Select
Range("K2:P2").Select
ActiveSheets.Paste
Next counter
End


When I run the debugger, I get runtime error 424 "Object required"

Any suggestions??? Thanks so much in advance for your help!
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Possibly

Code:
Sub xxx()
Dim LR As Long
LR = Range("A" & Rows.Count).End(xlUp).Row
Range("A" & LR & ":F" & LR).Copy Destination:=Sheets("Sheet2").Range("K2")
Application.CutCopyMode = False
End Sub
 
Upvote 0
VoGII,

Thanks for the reply! The code works like a charm!

Can I use the same range you used to copy data to paste the data (rather than just K2) in order to paste new data under the previously pasted data (ie the first set is pasted to K2 the next to K3 etc.)?

Thanks again for all your help!!
 
Upvote 0
Try

Code:
Sub xxx()
Dim LR1 As Long, LR2 As Long
LR1 = Range("A" & Rows.Count).End(xlUp).Row
LR2 = Sheets("Sheet2").Range("K" & Rows.Count).End(xlUp).Row
Range("A" & LR1 & ":F" & LR1).Copy Destination:=Sheets("Sheet2").Range("K" & LR2 + 1)
Application.CutCopyMode = False
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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
Back
Top