i am trying to create a macro to search for a specific string within a given range and then output to a different column of the same row, for example, in the following code i was attempting to search within column H for "Stage 2" and each time time it occurred, I wanted it to output "Stage 2" to column A for that row. the problem is that i keep getting runtime error 91: Object variable or With block variable not set and when i click debug the portion of code from "stage2 = Selection.Find" to ".Activate)" is highlighted. i suspect this is not that difficult of a macro but i just don't know what i'm doing
Dim Stage2 As Range
For i = 1 To 30000
Range("H" & i).Select
Stage2 = Selection.Find(What:="Stage 2", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
If Stage2 <> "" Then
Range("A" & i).Formula = "Stage 2"
End If
Next i
Dim Stage2 As Range
For i = 1 To 30000
Range("H" & i).Select
Stage2 = Selection.Find(What:="Stage 2", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
If Stage2 <> "" Then
Range("A" & i).Formula = "Stage 2"
End If
Next i