Hello everybody
below is the code ready to use
need to be fixed please
one problem is that you have to enter manually every time range of values you are looking for
and i need it to check range of values row by row automatically untill the table is ended
another problem is that the code returns the answer as value on the screen box and i need it to enter the value near the row which was checked right now and to continue to another row and so on until the table is ended.
the code works perfect on excel 2007
thank you everybody
Sub LoopUntilSpecificValue()
'UpdatebyExtendoffice20161222
Dim fStr As String
Dim strActAddress As String
Dim fbool As Boolean
Dim cnt As Long, cntRow As Long
Dim xRg As Range, yRg As Range, zRg As Range
fbool = False
strActAddress = ""
cnt = 0
On Error Resume Next
Set zRg = ActiveSheet.UsedRange
cntRow = zRg.Rows.Count
Set xRg = Application.InputBox _
(Prompt:="Range select..", Title:="Kutools for Excel", Type:=8)
fStr = Application.InputBox _
(Prompt:="Search string?", Title:="Kutools for Excel", Type:=2)
Application.ScreenUpdating = False
For Each yRg In xRg
If yRg.Row > cntRow Then
MsgBox "Value not found ", vbInformation, "Kutools for Excel"
Application.ScreenUpdating = True
Exit Sub
End If
If yRg.Value2 = fStr Then
Application.ScreenUpdating = True
yRg.Activate
fbool = True
strActAddress = yRg.Address
MsgBox "Value found in cell " & strActAddress, vbInformation, "Kutools for Excel"
Exit Sub
Else
cnt = cnt + 1
End If
Next yRg
If cnt = xRg.Count Then
MsgBox "Value not found ", vbInformation, "Kutools for Excel"
End If
Application.ScreenUpdating = True
End Sub
Bookmarks