ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Use of sheet codename in codeline - How? (https://www.excelbanter.com/excel-programming/366038-use-sheet-codename-codeline-how.html)

Jim May

Use of sheet codename in codeline - How?
 
Just spend 20-30 minutes going thru the Google Archive
Looking for an answer to my subject line

After 19-29 minutes of confusion, I just came up with the below code;
It seems to work -- but I'm asking "Is there a "gotch-Cha"
Associated with it? Seems simple enough - In the Interface my 3rd of 3
sheets shows "Page3" -- but of course in the VBA Properties Window
(Name) box I show MySheet3codename

Sub Selectsheettest()
MySheet3codename.Activate
Range("B4").Value = "hello - You made it !!"
End Sub


Dave Peterson

Use of sheet codename in codeline - How?
 
There's always gotcha's when you rely on being on the active sheet.

I would think that this would be better:

MySheet3codename.Range("B4").Value = "hello - You made it !!"

Codenames are much more difficult for the average user to screw up, er, change.
I think you'll be much happier with your code using codenames when the worksheet
name changes.

Jim May wrote:

Just spend 20-30 minutes going thru the Google Archive
Looking for an answer to my subject line

After 19-29 minutes of confusion, I just came up with the below code;
It seems to work -- but I'm asking "Is there a "gotch-Cha"
Associated with it? Seems simple enough - In the Interface my 3rd of 3
sheets shows "Page3" -- but of course in the VBA Properties Window
(Name) box I show MySheet3codename

Sub Selectsheettest()
MySheet3codename.Activate
Range("B4").Value = "hello - You made it !!"
End Sub


--

Dave Peterson

Don Guillett

Use of sheet codename in codeline - How?
 
Sub sheetnames()
MsgBox Sheets("sheet5").Range("b4")
MsgBox Sheet5.Range("b4")
MsgBox Sheets(5).Range("b4") 'index of location
End Su

--
Don Guillett
SalesAid Software

"Jim May" wrote in message
news:9ivpg.44099$fG3.6036@dukeread09...
Just spend 20-30 minutes going thru the Google Archive
Looking for an answer to my subject line

After 19-29 minutes of confusion, I just came up with the below code;
It seems to work -- but I'm asking "Is there a "gotch-Cha"
Associated with it? Seems simple enough - In the Interface my 3rd of 3
sheets shows "Page3" -- but of course in the VBA Properties Window (Name)
box I show MySheet3codename

Sub Selectsheettest()
MySheet3codename.Activate
Range("B4").Value = "hello - You made it !!"
End Sub




Jim May

Use of sheet codename in codeline - How?
 
Dave, Thanks for the closure (of this issue).
Jim May

"Dave Peterson" wrote in message
:

There's always gotcha's when you rely on being on the active sheet.

I would think that this would be better:

MySheet3codename.Range("B4").Value = "hello - You made it !!"

Codenames are much more difficult for the average user to screw up, er, change.
I think you'll be much happier with your code using codenames when the worksheet
name changes.

Jim May wrote:


Just spend 20-30 minutes going thru the Google Archive
Looking for an answer to my subject line

After 19-29 minutes of confusion, I just came up with the below code;
It seems to work -- but I'm asking "Is there a "gotch-Cha"
Associated with it? Seems simple enough - In the Interface my 3rd of 3
sheets shows "Page3" -- but of course in the VBA Properties Window
(Name) box I show MySheet3codename

Sub Selectsheettest()
MySheet3codename.Activate
Range("B4").Value = "hello - You made it !!"
End Sub



--

Dave Peterson




All times are GMT +1. The time now is 06:46 AM.

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