Help with a macro

bpflyr

Board Regular
Joined
Nov 7, 2005
Messages
116
I have two workbooks, 'Data Entry'! and 'Log Entry'!. The macro listed below will copy 4 rows of data from 'Data Entry'! and paste it into 'Log Entry'!.
(The macro is in 'Log Entry'!.

Can anyone please add to my macro so that each time I run it, the macro will look for the next blank row in 'Log Entry'! and do it's paste there? I am erasing all the data in 'Data Entry'! after each use.

Thanks in advance. Here's the macro:

Windows("BDataEntry.xls").Activate
Range("A4:AG8").Select
Selection.Copy
Windows("BLogbook.XLS").Activate
Selection.PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=True _
, Transpose:=False
End Sub
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Code:
Dim wb as workbook, pb as workbook

set pb = workbooks("BLogbook.XLS")
set wb =workbooks("BDataEntry.xls")

wb.sheets("Data Entry").Range("A4:AG8").copy wb.sheets("Log book").range("A65535").end(xlup).offset(1,0).pastespecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=True _ 
, Transpose:=False 

End Sub

HTH
Cal

PS-You dont' specifiy which worksheet you are working with, so I used Data Entry and Log Book. You will need to update.
 
Upvote 0
Thanks for the macro so quickly, but I keep getting a syntax error. The macro is placed in Log Entry. I am pasting rows 4 through 8 from Data Entry into Log Entry, then erasing the data in Data Entry and starting over.

Can we try again? Thank You!

p.s. The workbooks and worksheets have the same name (just one worksheet per workbook)
 
Upvote 0
bpflyr,
Sorry, I forgot the Pastespecail has to be a seperate command. If it was just a paste, then it all could be included on 1 line.

Code:
Private Sub CommandButton1_Click()
Dim wb As Workbook, pb As Workbook

Set pb = Workbooks("BLogbook.XLS")
Set wb = Workbooks("BDataEntry.xls")

wb.Sheets("Data Entry").Range("A4:AG8").Copy
wb.Sheets("Log book").Range("A65535").End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlAll, Operation:=xlNone, SkipBlanks:=True _
, Transpose:=False
End Sub

HTH
Cal
 
Upvote 0

Forum statistics

Threads
1,203,236
Messages
6,054,292
Members
444,715
Latest member
GlitchHawk

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