
06-18-2009, 07:29 PM
|
 |
Forum Moderator
|
|
Join Date: 15 Jan 2005
Location: San Francisco, Ca
MS Office Version:2000, 2003, & read 2007
Posts: 10,537
|
|
|
Re: Modify code to hide rows based on the contents in a cell.
Hello Clayton,
When you need to check a large number of cells, it is faster to store the cell values in a Variant Array. Also, using the Like operator is faster way to search for and match text in a string.
Code:
Sub HideRows()
Dim R As Long
Dim Rng As Range
Dim X As Variant
Set Rng = Worksheets("excel").Range("B7:B900")
X = Rng.Value
For R = UBound(X, 1) To 1 Step -1
If LCase(X(R, 1)) Like "*solar*" Then
Rng.Rows(R).Hidden = True
End If
Next R
End sub
__________________
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [code] before the first line of code and [/code] after the last line of code.2. Thank those who have helped you by Clicking the scales above each post. 3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
|