Mackeral
Board Regular
- Joined
- Mar 7, 2015
- Messages
- 249
- Office Version
- 365
- Platform
- Windows
I am looking in a column by searching for a partial matche. The problem iwth this code is that it skips over every second find.
The problem is with the "Rng" variable:: I increase it by 1 column, but if the next row contains what should be findable, it doesn't find it.
And it use to work a few days ago. I also notice that I have a terrible time working on weekends because I'm guessing that
they are trying out a test version code then. And it works again on Monday.
Code
The following are sequntial cells in the seadhed column:
The problem is with the "Rng" variable:: I increase it by 1 column, but if the next row contains what should be findable, it doesn't find it.
And it use to work a few days ago. I also notice that I have a terrible time working on weekends because I'm guessing that
they are trying out a test version code then. And it works again on Monday.
Code
VBA Code:
Sub Find_Test()
Rng = "G4:G455"
Look_For = "Computer"
Look_At = x{Part
Case_Arg = False
' Lookup a String in a Sheet and return its address in ROW and COL.
Found = ""
If InStr(Rng, ":") = 0 Then Rng = Rng & ":" & Rng
Do
With ACCOUNTS.Range(Rng)
Set Hold = .Find(What:=Look_Up, _
LookIn:=xlValues, _
LookAt:=Look_At, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=Case_Arg)
End With
If Hold Is Nothing Then
Debug.Print Line
Stop
Else
' Extra test to be sure
Ans_Row = Hold.Row
Ans_Col = Hold.Column
Rng = Make_Range(Ans_Row + 1, Ans_Col, -1, Ans_Col)
Line = Line & vbCr & Hold & ", " & Ans_Row
End If
Loop
End Function ' Find_String
The following are sequntial cells in the seadhed column:
This is the output of the program with the fiound line numbers: Communications:Computer, 117 Computer:Web, 119 Computer:Taxable, 121 Computer:Hardware, 123 Computer:Service, 125 Computer:Supplies, 126 | ||||||||||