Djblois
07-10-2008, 01:21 PM
I created a quick code to search all open workbooks and all the sheets in them for the user selected text. Here is the code I created:
Dim i As Long, j As Long
Dim wsTest As Worksheet
stgFind = Me.tbFind
Me.Hide
For i = 1 To Workbooks.Count
For j = 1 To Worksheets.Count
Set wsTest = ActiveSheet
wsTest.Cells.Find(What:=stgFind, After:=wsTest.Range("A1"), LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Next j
Next i
DoEvents
Me.Show
It keeps telling me object variable or With block not set on the find line. I know it is probably something so small that I can't find. I also set stgFind as a public variable.
Dim i As Long, j As Long
Dim wsTest As Worksheet
stgFind = Me.tbFind
Me.Hide
For i = 1 To Workbooks.Count
For j = 1 To Worksheets.Count
Set wsTest = ActiveSheet
wsTest.Cells.Find(What:=stgFind, After:=wsTest.Range("A1"), LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
Next j
Next i
DoEvents
Me.Show
It keeps telling me object variable or With block not set on the find line. I know it is probably something so small that I can't find. I also set stgFind as a public variable.