View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Serge[_2_] Serge[_2_] is offline
external usenet poster
 
Posts: 11
Default Run-time error when trying to work with different sheet

Try either Worksheets("Sheet1").Range("A1:Q36").Copy/Paste/Select (whatever
Range method you need)
Or Range("Sheet!A1:Q36").Copy/Paste/Select (whatever Range method you need)

In these cases I like to use VB's WITH to save the time
for example

With ActiveWorkbook.Worksheets("Sheet1")
.Range("A1:Q36").Select
... and so on
End With


"TBA" wrote in message
...
Excel 97
Windows 2k Pro

I have a command button on sheet2 that needs to do some "stuff" on sheet1
and then copy said "stuff" back onto sheet2. This is a stripped down
example of code for my command button on sheet2:

Private Sub cmd_RankBest_Click()
Worksheets("Sheet1").Select
Range("A1:Q36").Select 'selecting a range on sheet1
End Sub

But, I'm getting a run-time error '1004':
Select method of Range class failed

Is my code flawed?

Any insights greatly appreciated.

-gk-