Using Excel 2010.
I want Excel to alert me if a cell value is NOT equal Base or 2*Base, but when a call is NOT Base, it could be 2*Base, or vice versa; hence Excel always tell me it is wrong.
How should I modify my below code? Thank you
Sub SubTotal_test()
Dim k, i, j, minim, countleft, base, tmp_row, Last_Row, rw As Integer
base = InputBox("State the number of items")
Last_Row = ActiveWorkbook.ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row
For i = Last_Row + 1 To 1 Step -1
If (ActiveWorkbook.ActiveSheet.Cells(i, 3) = "L" And ActiveWorkbook.ActiveSheet.Cells(i, 11) <> base) Then
If (ActiveWorkbook.ActiveSheet.Cells(i, 3) = "L" And ActiveWorkbook.ActiveSheet.Cells(i, 11) <> (2 * base)) Then
MsgBox "There is an error with the SubTotal. Please change manually."
Exit For
End If
Else
'MsgBox "SubTotal OK"
ActiveWorkbook.ActiveSheet.Cells(i, 11).Select
End If
Next i
End Sub
I want Excel to alert me if a cell value is NOT equal Base or 2*Base, but when a call is NOT Base, it could be 2*Base, or vice versa; hence Excel always tell me it is wrong.
How should I modify my below code? Thank you
Sub SubTotal_test()
Dim k, i, j, minim, countleft, base, tmp_row, Last_Row, rw As Integer
base = InputBox("State the number of items")
Last_Row = ActiveWorkbook.ActiveSheet.Cells(Rows.Count, 2).End(xlUp).Row
For i = Last_Row + 1 To 1 Step -1
If (ActiveWorkbook.ActiveSheet.Cells(i, 3) = "L" And ActiveWorkbook.ActiveSheet.Cells(i, 11) <> base) Then
If (ActiveWorkbook.ActiveSheet.Cells(i, 3) = "L" And ActiveWorkbook.ActiveSheet.Cells(i, 11) <> (2 * base)) Then
MsgBox "There is an error with the SubTotal. Please change manually."
Exit For
End If
Else
'MsgBox "SubTotal OK"
ActiveWorkbook.ActiveSheet.Cells(i, 11).Select
End If
Next i
End Sub