I am writing a macro for an excel document. it takes a string from a list of strings in column "R" and searches ALL through column "J" to find the string. If it finds the string, it serches the columns "L" and "N" to find out if the numbers are the same against that string on "J". if it does, It highlights the corresponding string at Column "R".
This is the code I wrote:
Public Sub FindApproved()
Dim rnge, rnge1 As Range
Dim selectedRowNum As Long
Dim lAmt, nAmt As Currency
Dim referenceNum As String
Dim paymentStatus As String
Dim num As String
Dim isTransactionApproved As Boolean
isTransactionApproved = False
For Each rnge In Selection.Rows
selectedRowNum = rnge.Row
referenceNum = rnge.Columns("R").Value
For Each rnge1 In Selection.Rows
Dim start As Characters
Dim charCount As Integer
If (referenceNum = Mid$((rnge1.Columns("J").Value), start = R, charCount = 7)) Then
num = referenceNum
Else
End If
Next rnge1
If (num = referenceNum) Then
If (rnge.Columns("L").Value = lAmt And rnge.Columns("N").Value = _
"lAmt" And rnge.Columns("K").Value = "Approved") Then
isTransactionApproved = True
Range(num).Interior.ColorIndex = 36
End If
End If
Next rnge
End Sub
But when I stepInto it, it gives me a runtime error("Run-time error '91': Object variable or with block variable not set"). PLEASE HELP ME QUICKLY BECAUSE I AM TO DELIVER IT LATER TODAY. THANKS TO THAT BLESSED PERSON IN ADVANCE FOR YOUR HELP.