#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Or Like

In Excel2000, I have the following code:

For Each cll In Range("b8:b380")

' Rows to Hide take out Others if Others is to be shown
If cll Like "Comp $ Program*" Or cll Like "FC Program*" _
Or cll Like "Ship*" _
Or cll Like "Duty*" Or cll Like "Others*" _
Or cll Like "COS*" Or cll Like "LC" _
Or cll Like "Mark*" Or cll Like "Check*" _
Then
cll.Select
Selection.EntireRow.Hidden = True
End If
Next

Actually, I have many more "Or cll Like" lines that I edited out. Is
there another way to code this than using so many multiple Or's?

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Or Like

Maybe just build a list and go through them.

Option Explicit
Sub testme()

Dim cll As Range
Dim myList As Variant
Dim iCtr As Long
Dim FoundIt As Boolean

myList = Array("Comp $ Program", _
"FC Program", _
"Ship", _
"Duty", _
"Others", _
"Cos", _
"LC", _
"Mark", _
"Check")

For Each cll In Range("b8:b380").Cells
FoundIt = False
For iCtr = LBound(myList) To UBound(myList)
If LCase(cll.Value) Like LCase(myList(iCtr) & "*") Then
FoundIt = True
Exit For
End If
Next iCtr
Next cll
If FoundIt = True Then
cll.EntireRow.Hidden = True
End If
End Sub

I added the lcase stuff--you may not want it.

snax500 wrote:

In Excel2000, I have the following code:

For Each cll In Range("b8:b380")

' Rows to Hide take out Others if Others is to be shown
If cll Like "Comp $ Program*" Or cll Like "FC Program*" _
Or cll Like "Ship*" _
Or cll Like "Duty*" Or cll Like "Others*" _
Or cll Like "COS*" Or cll Like "LC" _
Or cll Like "Mark*" Or cll Like "Check*" _
Then
cll.Select
Selection.EntireRow.Hidden = True
End If
Next

Actually, I have many more "Or cll Like" lines that I edited out. Is
there another way to code this than using so many multiple Or's?

Thanks


--

Dave Peterson
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



All times are GMT +1. The time now is 01:05 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"