I have a VBA script in Excel to search for a value matching the one in "Book1" then checking to see if the cell two columns over in "Book2" matches? I cannot get it to work. It finds all of the instances of the first match, but it will not compare value1 to value2 in the 2nd column. Here is my script:
' Checking to see if the part number and annual quantity exist
Workbooks.Open Filename:= "test.xls"
With Worksheets(1).Range("C4:C6000"
Set c = .Find(P1, LookIn:=xlValues)
If Not c Is Nothing Then
firstaddress = c.Address
Do
If Range(c.Address).Offset(columnoffset:=2).Value = Qty1 Then
MsgBox prompt:="Sorry, that has already been quoted!", Title:="Duplicate Quote!!"
End If
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstaddress
End If
I know that the first line after the 'Do' statement is bombing out. It never ends up equaling when it should! I am pretty new at this, so any suggestions are deeply appreciated!! TIA!
' Checking to see if the part number and annual quantity exist
Workbooks.Open Filename:= "test.xls"
With Worksheets(1).Range("C4:C6000"
Set c = .Find(P1, LookIn:=xlValues)
If Not c Is Nothing Then
firstaddress = c.Address
Do
If Range(c.Address).Offset(columnoffset:=2).Value = Qty1 Then
MsgBox prompt:="Sorry, that has already been quoted!", Title:="Duplicate Quote!!"
End If
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstaddress
End If
I know that the first line after the 'Do' statement is bombing out. It never ends up equaling when it should! I am pretty new at this, so any suggestions are deeply appreciated!! TIA!