Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run-time error when trying to work with different sheet
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- |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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- |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run-time error when trying to work with different sheet
With XL97, you need to set the TakeFocusOnClick property of the
command button to False. In article , "TBA" wrote: 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- |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run-time error when trying to work with different sheet
Already did that, doesn't help.
-gk- "J.E. McGimpsey" wrote in message ... With XL97, you need to set the TakeFocusOnClick property of the command button to False. In article , "TBA" wrote: 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- |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run-time error when trying to work with different sheet
TBA,
Seems Excel wants the sheet specified... this works Private Sub cmd_RankBest_Click() Worksheets("Sheet1").Select Worksheets("Sheet1").Range("A1:Q36").Select 'selecting a range on sheet1 End Sub -- sb "TBA" wrote in message ... Already did that, doesn't help. -gk- "J.E. McGimpsey" wrote in message ... With XL97, you need to set the TakeFocusOnClick property of the command button to False. In article , "TBA" wrote: 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- |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run-time error when trying to work with different sheet
"steve" wrote in message ... TBA, Seems Excel wants the sheet specified... this works Private Sub cmd_RankBest_Click() Worksheets("Sheet1").Select Worksheets("Sheet1").Range("A1:Q36").Select 'selecting a range on sheet1 End Sub Thanks Steve! You were on the right track. After Googling this morning I got a tip where I used Worksheets("Sheet1").Select ActiveSheet.Range("A1:Q36").Select 'selecting a range on sheet1 Basically you were right about Excel wanting the sheet specified. Oh I love this stuff! ;) -gk- |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Run-time error when trying to work with different sheet
Yep,
I just got finished doing some code and went round and round on some similar issues until I got it right... F&F (fun and frustrating). Keep on Exceling! -- sb "TBA" wrote in message ... "steve" wrote in message ... TBA, Seems Excel wants the sheet specified... this works Private Sub cmd_RankBest_Click() Worksheets("Sheet1").Select Worksheets("Sheet1").Range("A1:Q36").Select 'selecting a range on sheet1 End Sub Thanks Steve! You were on the right track. After Googling this morning I got a tip where I used Worksheets("Sheet1").Select ActiveSheet.Range("A1:Q36").Select 'selecting a range on sheet1 Basically you were right about Excel wanting the sheet specified. Oh I love this stuff! ;) -gk- |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
extracting totals from 1 work sheet to another work work sheet | Excel Discussion (Misc queries) | |||
chart error message / work sheet not open ? | Charts and Charting in Excel | |||
Creating a Work place time sheet. | Excel Worksheet Functions | |||
How do I retrive my time sheet from AmeriCorps Work In Progress? | Setting up and Configuration of Excel | |||
How do I change . to : when input in a time sheet by error | New Users to Excel |