ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   CodeName Referencing Help (https://www.excelbanter.com/excel-programming/382570-codename-referencing-help.html)

AucklandAssault

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"

Chip Pearson

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"




AucklandAssault

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"





Dana DeLouis

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"








All times are GMT +1. The time now is 11:45 PM.

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