Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default CodeName Referencing Help

I want to exclude 4 worksheets from my macro. Is there are better way to
write the below?

If Project.CodeName < "Sheet01" And Project.CodeName < "Sheet02" And
Project.CodeName < "Sheet03" And Project.CodeName < "Sheet04"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default CodeName Referencing Help

I find that a Select Case statement is easier to understand and maintain.

Select Case project.CodeName
Case "Sheet01", "Sheet02", "Sheet03", "Sheet04"
'''''''''''''''
' do nothing
'''''''''''''''
Case Else
'''''''''''''''
' do something
'''''''''''''''
End Select



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"AucklandAssault" wrote in
message ...
I want to exclude 4 worksheets from my macro. Is there are better way to
write the below?

If Project.CodeName < "Sheet01" And Project.CodeName < "Sheet02" And
Project.CodeName < "Sheet03" And Project.CodeName < "Sheet04"



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default CodeName Referencing Help

Thanks a lot. Just learning so the help is appreciated.

"Chip Pearson" wrote:

I find that a Select Case statement is easier to understand and maintain.

Select Case project.CodeName
Case "Sheet01", "Sheet02", "Sheet03", "Sheet04"
'''''''''''''''
' do nothing
'''''''''''''''
Case Else
'''''''''''''''
' do something
'''''''''''''''
End Select



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"AucklandAssault" wrote in
message ...
I want to exclude 4 worksheets from my macro. Is there are better way to
write the below?

If Project.CodeName < "Sheet01" And Project.CodeName < "Sheet02" And
Project.CodeName < "Sheet03" And Project.CodeName < "Sheet04"




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 947
Default CodeName Referencing Help

Hi. Select Case is the way to go.
Just to mention an alternative if your pattern is rather simple as in your
example...

Sub Demo()
Dim cn
'cn = Project.CodeName
cn = "Sheet02" '<- Test
If cn Like "Sheet0[1234]" Then
Debug.Print "Exclude this"
End If
End Sub

--
HTH :)
Dana DeLouis
Windows XP & Office 2003


"AucklandAssault" wrote in
message ...
Thanks a lot. Just learning so the help is appreciated.

"Chip Pearson" wrote:

I find that a Select Case statement is easier to understand and maintain.

Select Case project.CodeName
Case "Sheet01", "Sheet02", "Sheet03", "Sheet04"
'''''''''''''''
' do nothing
'''''''''''''''
Case Else
'''''''''''''''
' do something
'''''''''''''''
End Select



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"AucklandAssault" wrote in
message ...
I want to exclude 4 worksheets from my macro. Is there are better way
to
write the below?

If Project.CodeName < "Sheet01" And Project.CodeName < "Sheet02" And
Project.CodeName < "Sheet03" And Project.CodeName < "Sheet04"






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
string to codename rk0909 Excel Discussion (Misc queries) 4 September 25th 08 10:57 PM
codename help Gary Keramidas Excel Programming 14 October 31st 05 12:32 AM
Referencing worksheet CODENAME in a chart object. Bing Excel Discussion (Misc queries) 1 February 15th 05 01:01 AM
Referencing worksheet CODENAME in a chart object. Bing Excel Programming 2 February 14th 05 07:08 PM
Worksheet codename Andy Excel Programming 4 December 2nd 03 04:12 PM


All times are GMT +1. The time now is 01:33 AM.

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

About Us

"It's about Microsoft Excel"