View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Nichevo Nichevo is offline
external usenet poster
 
Posts: 18
Default Creating a Hide Macro

Yes is perfectly possible you could use something like this
Sub HideRows
Dim Searchtxt As String
Dim ws As Worksheet
Searchtxt = "case"
Set ws = ThisWorkbook.Worksheets("Name of Worksheet")
For row = 2 to 100
If ws.Cells(row, 4) < Searchtxt And ws.Cells(row, 4) < "" Then 'Column D is numbered 4
ws.Rows(Row).EntireRow.Hidden = True
End If
Next row
End Sub

and it undo it just do:

Sub UnHideRows
Dim Searchtxt As String
Dim ws As Worksheet
Searchtxt = "case"
Set ws = ThisWorkbook.Worksheet("Name of Worksheet")
For row = 2 to 100
ws.Rows(Row).EntireRow.Hidden = false
Next row
End Sub

problem with this is that it looks for an exact match so if its a capital Case it will be false through this is easy to get around using something like the Upper function