I have a document that is basically a big Table of Contents, with hyperlinks to helpful sites. I have 2 macros- the first is basically a keyword search, that hides all rows that don't include the keyword that the user enters into cell H2. The second is a simple command to unhide all of the rows. Every time I open the document, I get the Run-time error 9: Subscript out of range. Can someone tell this VBA rookie how to keep this error from coming up?
Here's my code:
Thanks!
Here's my code:
Code:
Sub Search()
Dim myans As Range
Dim location As Range
Dim Text As String
Application.ScreenUpdating = False
Text = Range("H2")
For Count = 3 To 250
With ActiveSheet.Range(Cells(Count, 3), Cells(Count, 12))
Set myans = .Find(What:=Text, LookAt:=xlPart, SearchOrder:=xlByRows)
If myans Is Nothing Then
Cells(Count, 1).EntireRow.Hidden = True
Else
Cells(Count, 1).EntireRow.Hidden = False
End If
End With
Next Count
End Sub
Code:
Sub UnhideAll()
ActiveSheet.Range("A1:A300").EntireRow.Hidden = False
End Sub
Thanks!