Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Case select and sheet codename

Hi everyone,

I'm replacing all sheet tab names with sheet codenames in my project.

I'm getting Runtime error 438. Object doesn't support this property or method.

I'm guessing it's this part of the code. ???

Select Case sht.CodeName
Case Sheet33, Sheet25, Sheet28, Sheet27
sht.Visible = xlVeryHidden
Case Else
sht.Visible = True
End Select

Hoping that someone can help :-)

--
Thank you
Annie
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Case select and sheet codename

sht.codename is a string.

I'd try:

Select Case sht.CodeName
Case "Sheet33", "Sheet25", "Sheet28", "Sheet27"

Annie Whitley wrote:

Hi everyone,

I'm replacing all sheet tab names with sheet codenames in my project.

I'm getting Runtime error 438. Object doesn't support this property or method.

I'm guessing it's this part of the code. ???

Select Case sht.CodeName
Case Sheet33, Sheet25, Sheet28, Sheet27
sht.Visible = xlVeryHidden
Case Else
sht.Visible = True
End Select

Hoping that someone can help :-)

--
Thank you
Annie


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Case select and sheet codename

Thanks for your help Dave :-)
--
Thank you
Annie


"Dave Peterson" wrote:

sht.codename is a string.

I'd try:

Select Case sht.CodeName
Case "Sheet33", "Sheet25", "Sheet28", "Sheet27"

Annie Whitley wrote:

Hi everyone,

I'm replacing all sheet tab names with sheet codenames in my project.

I'm getting Runtime error 438. Object doesn't support this property or method.

I'm guessing it's this part of the code. ???

Select Case sht.CodeName
Case Sheet33, Sheet25, Sheet28, Sheet27
sht.Visible = xlVeryHidden
Case Else
sht.Visible = True
End Select

Hoping that someone can help :-)

--
Thank you
Annie


--

Dave Peterson
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 309
Default Case select and sheet codename

Hi Annie,

When the error message box occurs, try pressing the
"Debug" button and VBA will highlight exactly where
the error is occurring. The error is probably occurring
at the line that says:

Case Sheet33, Sheet25, Sheet28, Sheet27

Try placing double quotes around each sheet name
as follows:

Case "Sheet33", "Sheet25", "Sheet28", "Sheet27"

Hope that helps!

Robert



"Annie Whitley" wrote in message
...
Hi everyone,

I'm replacing all sheet tab names with sheet codenames in my project.

I'm getting Runtime error 438. Object doesn't support this property or
method.

I'm guessing it's this part of the code. ???

Select Case sht.CodeName
Case Sheet33, Sheet25, Sheet28, Sheet27
sht.Visible = xlVeryHidden
Case Else
sht.Visible = True
End Select

Hoping that someone can help :-)

--
Thank you
Annie


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Case select and sheet codename

Cheers Robert :-)
--
Thank you
Annie


"Robert Crandal" wrote:

Hi Annie,

When the error message box occurs, try pressing the
"Debug" button and VBA will highlight exactly where
the error is occurring. The error is probably occurring
at the line that says:

Case Sheet33, Sheet25, Sheet28, Sheet27

Try placing double quotes around each sheet name
as follows:

Case "Sheet33", "Sheet25", "Sheet28", "Sheet27"

Hope that helps!

Robert



"Annie Whitley" wrote in message
...
Hi everyone,

I'm replacing all sheet tab names with sheet codenames in my project.

I'm getting Runtime error 438. Object doesn't support this property or
method.

I'm guessing it's this part of the code. ???

Select Case sht.CodeName
Case Sheet33, Sheet25, Sheet28, Sheet27
sht.Visible = xlVeryHidden
Case Else
sht.Visible = True
End Select

Hoping that someone can help :-)

--
Thank you
Annie


.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Case select and sheet codename

Hi Annie,

The sheet codenames are strings so enclose the names in double quotes.

Case "Sheet33", "Sheet25", "Sheet28", "Sheet27"


--
Regards,

OssieMac


"Annie Whitley" wrote:

Hi everyone,

I'm replacing all sheet tab names with sheet codenames in my project.

I'm getting Runtime error 438. Object doesn't support this property or method.

I'm guessing it's this part of the code. ???

Select Case sht.CodeName
Case Sheet33, Sheet25, Sheet28, Sheet27
sht.Visible = xlVeryHidden
Case Else
sht.Visible = True
End Select

Hoping that someone can help :-)

--
Thank you
Annie

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Case select and sheet codename

Hi OssieMac,

That does the trick! Thank you :-)


--
Thank you
Annie


"OssieMac" wrote:

Hi Annie,

The sheet codenames are strings so enclose the names in double quotes.

Case "Sheet33", "Sheet25", "Sheet28", "Sheet27"


--
Regards,

OssieMac


"Annie Whitley" wrote:

Hi everyone,

I'm replacing all sheet tab names with sheet codenames in my project.

I'm getting Runtime error 438. Object doesn't support this property or method.

I'm guessing it's this part of the code. ???

Select Case sht.CodeName
Case Sheet33, Sheet25, Sheet28, Sheet27
sht.Visible = xlVeryHidden
Case Else
sht.Visible = True
End Select

Hoping that someone can help :-)

--
Thank you
Annie

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Case select and sheet codename

Annie,

As others have pointed out, you were missing the quotes around the
code names. Just FYI, if you are using code names in your code in
order to prevent problems that might occur if the user renames a
sheet, you can use the code name anywhere you would normally use the
worksheet's tab name. The code name doesn't change when the user
changes a tab name. For example

Sheet1.Range("A1").Value =1234

Moreover, you can change the code name of a worksheet to something
more meaningful that "Sheet3". In VBA, select the module in question
in the Project window, press F4 to display the Properties window if it
is not already visible, and change the Name property to the desired
name. Note that unlike a worksheet's tab name, the code name cannot
contains spaces or punctuation characters. Alpha-numeric only. Then
you can reference the sheet like

SummarySheet.Range("A1").Value = 1234

where SummarySheet is the new code name. This is obviously more
meaningful that just 'Sheet3'.

You can change code names via code. If you want to access the
worksheet via its tab name, use code like the following:

With ThisWorkbook
.VBProject.VBComponents( _
.Worksheets("Sheet Two").CodeName).Name = "NewCodeName"
End With

Or, if you know the current code name, use code like

ThisWorkbook.VBProject. _
VBComponents("CurrentCodeName").Name = "NewCodeName"

And, just for completeness, you can also use

ThisWorkbook.VBProject.VBComponents("MainSheet"). _
Properties("Name") = "AnotherName"

but this last method has no advantage over the other methods. Just yet
another way to do the same thing.

I often use code names rather than tab names in my projects to prevent
run time errors if the user changes a tab name. No matter how many
times you tell a user not to change the tab name, someone will always
do just that, screwing things up.

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]





On Sat, 6 Feb 2010 12:41:01 -0800, Annie Whitley
wrote:

Hi everyone,

I'm replacing all sheet tab names with sheet codenames in my project.

I'm getting Runtime error 438. Object doesn't support this property or method.

I'm guessing it's this part of the code. ???

Select Case sht.CodeName
Case Sheet33, Sheet25, Sheet28, Sheet27
sht.Visible = xlVeryHidden
Case Else
sht.Visible = True
End Select

Hoping that someone can help :-)

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
Fastest way to select a sheet codename Robert Crandal Excel Programming 11 December 17th 09 07:14 AM
Selecting Sheet By Codename Kris_Wright_77 Excel Programming 4 December 16th 09 04:23 PM
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
Use of sheet codename in codeline - How? Jim May Excel Programming 3 July 1st 06 04:24 PM


All times are GMT +1. The time now is 03:58 AM.

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"