Hi All, I have some code I want to run which compares the last found value in one column with another. Depending on the row number, I want to do different things. Code:
The problem is, if lRow3 is greater than lRow1 or lRow2 then the first condition is fired.
...any idea what I am doing wrong? Thanks in advance.
Code:
lRowWS1 = sht1.Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row
lRow1 = sht1.Cells(sht1.Rows.Count, "A").End(xlUp).Row
lRow2 = sht1.Cells(sht1.Rows.Count, "B").End(xlUp).Row
lRow3 = sht1.Cells(sht1.Rows.Count, "D").End(xlUp).Row
If (lRow1 Or lRow2) < lRow3 Or (lRow1 Or lRow2) = lRow3 Then
Set nRange = Union(Range("A" & lRowWS1 + 1), Range("A" & lRowWS1 - 1), _
Range("B" & lRowWS1 + 1), Range("B" & lRowWS1 - 1), _
Range("C" & lRowWS1 + 1), Range("C" & lRowWS1 - 1), _
Range("D" & lRowWS1 + 1), Range("D" & lRowWS1), Range("D" & lRowWS1 - 1), _
Range("E" & lRowWS1 + 1), Range("E" & lRowWS1), Range("E" & lRowWS1 - 1))
Else:
Set nRange = Union(Range("A" & lRowWS1), Range("A" & lRowWS1 - 2), _
Range("B" & lRowWS1), Range("B" & lRowWS1 - 2), _
Range("C" & lRowWS1), Range("C" & lRowWS1 - 2), _
Range("D" & lRowWS1), Range("D" & lRowWS1 - 1), Range("D" & lRowWS1 - 2), _
Range("E" & lRowWS1 ), Range("E" & lRowWS1 - 1), Range("E" & lRowWS1 - 2))
End If
With nRange
.Locked = False
.FormulaHidden = False
.ClearContents
End With
...any idea what I am doing wrong? Thanks in advance.