Empty cells in For Loop
Do you mean that if a cell is empty then you don't care about the rest, that
is if an A is empty, you ignore that and all associated B's?
If so
For Each A In range1
If Len(A.Value) 0 Then
For Each B In range1
If Len(B.Value) 0 Then
If B.Value < A.Value Then
If Abs(A.Value - B.Value) <= testvalue Then
With Sheets("Test
Results").Range("A1").End(xlDown)
.Offset(1, 0).Value = "Interference"
.Offset(0, 1).Value = A.Value
.Offset(0, 1).Value = B.Value
End With
End If
End If
End If
Next B
End If
Next A
--
HTH
Bob Phillips
"Linking to specific cells in pivot table"
crosoft.com wrote in
message ...
I am trying to write a For Loop which runs all the populated cells in the
range through a calculation. My question is how do I make sure that empty
or
null cells aren't selected to be used in the calculation? Essentially I
just
want to ignore the empty/null cells. Below is the code for the loop in
case
this helps:
For Each A In range1
For Each B In range1
If B.Value < A.Value Then
If Abs(A - B) <= testvalue Then
Sheets("Test Results").Select
range("A1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, 0).Select
Selection.Value = "Interference"
ActiveCell.Offset(0, 1).Select
Selection.Value = A.Value
ActiveCell.Offset(0, 1).Select
Selection.Value = B.Value
End If
End If
Next
Next
|