ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Double search (https://www.excelbanter.com/excel-programming/377956-double-search.html)

JustLearning

Double search
 
I want to run 2 searches in one sub. Search 1 is looking for a blank cell, if
found then in that same row but column A - that number must then be searched
threw all my sheets. If all is found then it should return to the first
search and search the next blank cell. I have managed to create most of the
code but my code has this error. : Run time error 91 - object variable or
with block variable not set.
The code runs ok for the first search but then my variable c is set to
"nothing"

This is my code:
Sub find_2(ByVal g As Integer, ByVal d As Integer)
A = 1
Do
ActiveWorkbook.Worksheets(A).Activate

With Worksheets(A).Range("i1:i500")
Set c = .find("", LookIn:=xlValues)
If Not c Is Nothing Then
firstAddress = c.Address
Do
g = (c.Offset(0, -8))

Set c = .FindNext(c)

d = d + 1
j = 1
Do
ActiveWorkbook.Worksheets(j).Activate
With Worksheets(j).Range("a3:a500")
Set r = Columns("A").find(What:=g)
If Not r Is Nothing Then
End If
End With
j = j + 1
Loop Until j = 12

Loop While Not c Is Nothing And c.Address < firstAddress
End If
End With
A = A + 1
Loop Until A = 12

End Sub


Any help will be appreciated



All times are GMT +1. The time now is 10:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com