Question : Finding value in a Range

Hi All i need help this is excel/vba question
i worte the following code to find "OK" in the Range("Magna")
"Magna" is a dynamic range.
The hole point of this code is, to find "OK" in the Range("Magna") of cells  if it finds "OK" then call Procedure "MyCode"  
but its not giving me any error at the sametime its not working.
Pl help me to find out where the problem is........
Thank you  
Sub FindValue()
If Sheets("Sheet2").Range("B10").Value = True Then
    Application.ScreenUpdating = True
    Application.ScreenUpdating = False
    Dim rng1 As Range
    Dim rw As Integer, i As Integer
    Dim Found As Boolean
    Dim cf As String
    Dim SearchB As Range
Set rng1 = Worksheets("Sheet1").Range("Magna")
 rw = rng1.Rows.Count
 For i = 1 To rw
 cf = rng1.Cells(i, 1).Value
 Set SearchB = rng1.Find(what:="OK", LookIn:=xlValues, _
         LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
         MatchCase:=False)

 If SearchB Is Nothing Then
Found = False
ElseIf SearchB <> cf Then
Found = False
ElseIf SearchB = "" Then
Found = False
 ElseIf SearchB = cf Then
 Found = True
 End If
 If Found = True Then
 Sheets("Sheet3").Range("K1").Value = i
 Call MyCode()
End If
Next i
end if
end sub

Answer : Finding value in a Range

if that is the case try this:

Sub fv1()
Dim sRng As Range, fRng As Range, i As Integer
i = 1
Set sRng = Range("Magna")
Set fRng = sRng.Find(What:="OK", lookat:=xlPart)
If Not fRng Is Nothing Then
fAdd = fRng.Address
Do
Sheets("Sheet3").Range("K" & i).Value = fRng.Row: i = i + 1
Set fRng = sRng.FindNext(fRng)
Loop While fAdd <> fRng.Address
Call MyCode
End If
End Sub
Random Solutions  
 
programming4us programming4us