Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
bob bob is offline
external usenet poster
 
Posts: 52
Default This does not work: Range("A1").Select

Why do I get an error with this?


Private Sub CommandButton1_Click()
Sheets("Forecast").Select
Range("A1").Select
End Sub






  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default This does not work: Range("A1").Select

Hi

Probably because that code is in Sheet3. From there you have very limited power over
Sheet1. Put code like this in standard modules and call them from the sheets. Like:

Sub GoForecast()
Sheets("Forecast").Select
Range("A1").Select
End Sub

and in the sheet:

Private Sub CommandButton1_Click()
Call GoForecast
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please.

"Bob" wrote in message
...
Why do I get an error with this?


Private Sub CommandButton1_Click()
Sheets("Forecast").Select
Range("A1").Select
End Sub








  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default This does not work: Range("A1").Select

Private Sub CommandButton1_Click()
Sheets("Forecast").Select
Range("A1").Select
End Sub


Because the unqualified Range("A1").Select refers to the sheet containing
the button which is not the active sheet

Private Sub CommandButton1_Click()
With Sheets("Forecast")
.Select
.Range("A1").Select
End Sub


Should work.

--
regards,
Tom Ogilvy


"Bob" wrote in message
...
Why do I get an error with this?


Private Sub CommandButton1_Click()
Sheets("Forecast").Select
Range("A1").Select
End Sub








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
please change Range("AB30").Select to any cell Steved Excel Worksheet Functions 3 October 18th 09 10:03 PM
"Select method of Range class failed" Error Ayo Excel Discussion (Misc queries) 3 September 2nd 08 07:58 PM
Using "=randbetween" to select a number from a range of cells a0xbjzz Excel Worksheet Functions 4 August 4th 07 07:47 PM
Run-time error "1004" Select method of range class failed Tallan Excel Discussion (Misc queries) 3 March 7th 07 05:22 PM
Why doesn't "Workbook.Range("myrange").value" work? Brad Patterson Excel Programming 0 July 9th 03 01:24 AM


All times are GMT +1. The time now is 02:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"