Hey Everyone:
Below is a code I created (thanks to many Threads here on Tek-Tips) but get the Error Code 400 if I run this macro when I am in a different worksheet than "Master". I would like to create a button that is assigned to this macro but can't because of the Error Code. Not sure how to get around it.
Thanks.
DMo
Sub CopyPeriods()
Dim wsMaster As Worksheet, wsP1P4 As Worksheet, wsP5P8 As Worksheet, wsP9P12 As Worksheet
Set wsMaster = Sheets("Master")
Set wsP1P4 = Sheets("P1-P4")
Set wsP5P8 = Sheets("P5-P8")
Set wsP9P12 = Sheets("P9-P12")
wsMaster.Range("A1").CurrentRegion.ClearContents
wsP1P4.Range("Database1").Copy
wsMaster.Range("A1").Select
ActiveSheet.Paste
wsP5P8.Range("Database2").Copy
wsMaster.Range("A1").Select
Call ActivateNextBlankDown
ActiveSheet.Paste
wsP9P12.Range("Database3").Copy
wsMaster.Range("A1").Select
Call ActivateNextBlankDown
ActiveSheet.Paste
End Sub
Sub ActivateNextBlankDown()
ActiveCell.Activate
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
End Sub
Below is a code I created (thanks to many Threads here on Tek-Tips) but get the Error Code 400 if I run this macro when I am in a different worksheet than "Master". I would like to create a button that is assigned to this macro but can't because of the Error Code. Not sure how to get around it.
Thanks.
DMo
Sub CopyPeriods()
Dim wsMaster As Worksheet, wsP1P4 As Worksheet, wsP5P8 As Worksheet, wsP9P12 As Worksheet
Set wsMaster = Sheets("Master")
Set wsP1P4 = Sheets("P1-P4")
Set wsP5P8 = Sheets("P5-P8")
Set wsP9P12 = Sheets("P9-P12")
wsMaster.Range("A1").CurrentRegion.ClearContents
wsP1P4.Range("Database1").Copy
wsMaster.Range("A1").Select
ActiveSheet.Paste
wsP5P8.Range("Database2").Copy
wsMaster.Range("A1").Select
Call ActivateNextBlankDown
ActiveSheet.Paste
wsP9P12.Range("Database3").Copy
wsMaster.Range("A1").Select
Call ActivateNextBlankDown
ActiveSheet.Paste
End Sub
Sub ActivateNextBlankDown()
ActiveCell.Activate
Selection.End(xlDown).Select
Selection.End(xlDown).Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
End Sub