truzilla
07-11-2008, 08:40 AM
Hey everyone, so I have some code that looks for a specific value and a message box comes up with the cells that is either: greater than 1 OR less than -1. Unfortunately I can't find out how to say both in the same line to make the macro work. I have copied the code below for your reference. I just need to know how to say: greater than 1 OR less than -1
' Message box showing all checks that are less than -1
With ActiveSheet
LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To LastRow
If LCase(.Cells(i, TEST_COLUMN).Value) = "check" Then
LastCol = .Cells(i, .Columns.Count).End(xlToLeft).Column
For j = .Cells(i, TEST_COLUMN).Column + 4 To LastCol
' THIS IS WHERE I NEED TO EDIT THE NUMBER TO MAKE IT INCLUDE GREATER THAN 1 ALSO
If .Cells(i, j).Value < -1 Then
msg = msg & vbTab & .Cells(i, j).Address(False, False) & vbNewLine
End If
Next j
End If
Next i
If msg <> "" Then
MsgBox "The following CHECK cells are LESS than '-1': " & vbNewLine & msg
End If
End With
THANKS FOR ALL YOUR HELP! : pray2:
' Message box showing all checks that are less than -1
With ActiveSheet
LastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
For i = 1 To LastRow
If LCase(.Cells(i, TEST_COLUMN).Value) = "check" Then
LastCol = .Cells(i, .Columns.Count).End(xlToLeft).Column
For j = .Cells(i, TEST_COLUMN).Column + 4 To LastCol
' THIS IS WHERE I NEED TO EDIT THE NUMBER TO MAKE IT INCLUDE GREATER THAN 1 ALSO
If .Cells(i, j).Value < -1 Then
msg = msg & vbTab & .Cells(i, j).Address(False, False) & vbNewLine
End If
Next j
End If
Next i
If msg <> "" Then
MsgBox "The following CHECK cells are LESS than '-1': " & vbNewLine & msg
End If
End With
THANKS FOR ALL YOUR HELP! : pray2: