Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB Error Code 400 - Trying to Paste Worksheet from another

Status
Not open for further replies.

davidmo

Technical User
Apr 8, 2003
97
US
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


 


Hi,

Please post CODE question in

VBA Visual Basic for Applications (Microsoft) forum707

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top