Excel VB

G

Guest

I have the following code (copied from a macro) into VB as follows:

Private Sub CommandButton1_Click()

Sheets("Sheet1").Select


Range("B5:D17").Select
Selection.Copy
Sheets("Sheet3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("K22").Select


End Sub


When I run this from a button I get the following message - Runtime error 1004
Select method of Range class failed.

Can someone please help me with the proper syntax.

Thanks

Nigel
 
G

Guest

Hi Simon

Yes I do actually have those sheet names - however I have just solved the
problem - I did not use the Activate command and that is what has been
hanging my code up- it is now fixed. Thanks fro responding.

Private Sub CommandButton1_Click()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top