Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparing Values in 2 Different Worksheets 1

Status
Not open for further replies.

jennuhw

MIS
Apr 18, 2001
426
US
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!
 
I did some playing and figured it out.
fname = activeworkbook.name
Thanks!!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top