PDA

View Full Version : Cell comparison



CicoMico
08-27-2007, 03:32 AM
Hey! Have some problem here as usual :banghead: I have 2 workbooks. In wbk 1 I want to search for some value, then put it into var, switch to 2nd wbk and search column A from first to the last cell in row for this value. If it's not founded, then run some macro...

sample code:

workbook2.Activate

lastrow = Cells(Rows.Count, "A").End(xlUp).Row

For a = 1 To lastrow

If Cells(a, "A").Value <> XLZ Then

workbook1.Activate
Call SOME_MACRO

End If

Next a


My problem is, that it is not searching for some reason (at least it finds nothing). Any help or better solution? Thank you

p45cal
08-27-2007, 03:51 AM
Found = False
For a = 1 To lastrow
If Cells(a, "A").Value = XLZ Then
Found = True
Exit For
End if
Next a
If Found = False Then 'do what you need to do

CicoMico
08-27-2007, 05:48 AM
Found = False
For a = 1 To lastrow
If Cells(a, "A").Value = XLZ Then
Found = True
Exit For
End if
Next a
If Found = False Then 'do what you need to do


thanx dude, but it is not working for me... it makes me crazy!

geekgirlau
08-28-2007, 12:07 AM
What value is in the variable XLZ?