ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Select Sheet then Select Range (https://www.excelbanter.com/excel-programming/299721-select-sheet-then-select-range.html)

Gee[_2_]

Select Sheet then Select Range
 
I'm having trouble with a button I created. When clicked
it's supposed to go to sheet "SOURCE 1" and then to Cell
H77. I keep getting the message "Select Method of Range
Class has Failed"

Private Sub CommandButton31_Click()
Sheets("SOURCE 1").Select
Range("H77").Select
End Sub

Any ideas what I'm doing wrong?

Thank you for any help you can give me,
Gee

Frank Kabel

Select Sheet then Select Range
 
Hi
in most cases no need to select sheets / ranges. e.g. try:
Private Sub CommandButton31_Click()
dim wks as worksheet
dim rng as range
set wks = activeworkbook.workSheets("SOURCE 1")
set rng = wks.Range("H77")
msgbox rng.value
End Sub

--
Regards
Frank Kabel
Frankfurt, Germany

"Gee" schrieb im Newsbeitrag
...
I'm having trouble with a button I created. When clicked
it's supposed to go to sheet "SOURCE 1" and then to Cell
H77. I keep getting the message "Select Method of Range
Class has Failed"

Private Sub CommandButton31_Click()
Sheets("SOURCE 1").Select
Range("H77").Select
End Sub

Any ideas what I'm doing wrong?

Thank you for any help you can give me,
Gee



Trevor Shuttleworth

Select Sheet then Select Range
 
Gee

not sure quite why this works, but try it anyway:

Sheets("SOURCE 1").Select
With Sheets("SOURCE 1")
.Range("H77").Select
End With

Regards

Trevor


"Gee" wrote in message
...
I'm having trouble with a button I created. When clicked
it's supposed to go to sheet "SOURCE 1" and then to Cell
H77. I keep getting the message "Select Method of Range
Class has Failed"

Private Sub CommandButton31_Click()
Sheets("SOURCE 1").Select
Range("H77").Select
End Sub

Any ideas what I'm doing wrong?

Thank you for any help you can give me,
Gee




Gee[_2_]

Select Sheet then Select Range
 
Thanks, Trevor...worked perfectly!
Frank...that was useful, but I needed it to actually go to
the cell...though I'm going to keep that bit of
code 'cause I'm going to need it on another
project...you're psychic!
Gee
-----Original Message-----
Gee

not sure quite why this works, but try it anyway:

Sheets("SOURCE 1").Select
With Sheets("SOURCE 1")
.Range("H77").Select
End With

Regards

Trevor


"Gee" wrote in

message
...
I'm having trouble with a button I created. When

clicked
it's supposed to go to sheet "SOURCE 1" and then to Cell
H77. I keep getting the message "Select Method of Range
Class has Failed"

Private Sub CommandButton31_Click()
Sheets("SOURCE 1").Select
Range("H77").Select
End Sub

Any ideas what I'm doing wrong?

Thank you for any help you can give me,
Gee



.



All times are GMT +1. The time now is 08:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com