I created a script a while back, but there have been some minor changes to my data and for some reason I'm unable to figure out how to cope with the change.
Basically the code looks up a bunch of data in a string found in Column D of each row. It finds a date and replaces the current date in Column A. I have it searching for the word "DUE" because that clues us in to where the date is located.
However, not all strings in Column D have the word "DUE". If they don't have a "DUE" there is no date and the current date in Column A remains untouched.
Here is my code:
Part in bold is where I get an error saying it cannot find the value "DUE".
What is the proper way to move to the next row if I cannot find the word "DUE"?
Any suggestions would be appreciated.
Thanks!
Basically the code looks up a bunch of data in a string found in Column D of each row. It finds a date and replaces the current date in Column A. I have it searching for the word "DUE" because that clues us in to where the date is located.
However, not all strings in Column D have the word "DUE". If they don't have a "DUE" there is no date and the current date in Column A remains untouched.
Here is my code:
Rich (BB code):
'myVal = "Activity Category" which is found in Column B
'myVal2 = "DUE"
With Columns("B")
Set Found = .Find(What:=myVal, After:=.Cells(1, 1), LookIn:=xlValues, _
LookAt:=xlWhole, MatchCase:=False, SearchDirection:=xlNext)
trancode = Found.Address
With Found
For iRow = 1 To rng.Rows.Count
If .Offset(iRow + 1, 0).Value <> "Accrued Interest" Then
If Not myVal2 = Application.WorksheetFunction.Find(myVal2, .Offset(iRow + 1, 2), 1) Then
.Offset(iRow + 1, -1).Value = .Offset(iRow + 1, -1).Value
Else
.Offset(iRow + 1, -1).Value = Trim(Left(Mid(.Offset(iRow + 1, 2), Application.WorksheetFunction.Find(myVal2, .Offset(iRow + 1, 2), 1) + 4, 11), 11))
On Error Resume Next
End If
End If
Next iRow
End With
End With
Part in bold is where I get an error saying it cannot find the value "DUE".
What is the proper way to move to the next row if I cannot find the word "DUE"?
Any suggestions would be appreciated.
Thanks!