Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|