Trying to account for a field having a "0" or it was blanked out
Here is the code (there is some logic to determine start and end condition)
---------------
Sub UpdateSheetTest()
Dim i As Integer
Dim bStart As Boolean
Dim oneH As Long
bStart = False
For i = 1 To 100
If Cells(i, 2).Value = "Grand Total" Then Exit For ' define end of processing
If bStart = True Then
If Cells(i, 1).Value <> 0 Then ' insure there is a quantity defined in col A
'-------------- next line should say "if column 8 has a numeric value > 0" (account for BLANK)
If (Cells(i, .Value = 0 Or Cells(i, .Value = "") Then
Cells(i, 10).Value = Cells(i, 1).Value * Cells(i, 5).Value
Cells(i, 11) = "Used-1"
ElseIf (Cells(i, .Value <> 0 And Cells(i, <> "") Then ' use percentage discount from col H - Discount %
' ------- This line gives an error --- trying to apply a percentage calculation
' Cells(i, 10).Value = Cells(i, 1).Value * (Cells(i, 5).Value - (Cells(i, 5).Value * Cells(i, .Value) / 100)
Cells(i, 11) = "Used-2"
Else
Cells(i, 11) = "Used-None" ' unknown condition
End If
End If
End If
If Cells(i, 1).Value = "Qty." Then bStart = True ' define start
Next
End Sub
---------------------------
Here is the code (there is some logic to determine start and end condition)
---------------
Sub UpdateSheetTest()
Dim i As Integer
Dim bStart As Boolean
Dim oneH As Long
bStart = False
For i = 1 To 100
If Cells(i, 2).Value = "Grand Total" Then Exit For ' define end of processing
If bStart = True Then
If Cells(i, 1).Value <> 0 Then ' insure there is a quantity defined in col A
'-------------- next line should say "if column 8 has a numeric value > 0" (account for BLANK)
If (Cells(i, .Value = 0 Or Cells(i, .Value = "") Then
Cells(i, 10).Value = Cells(i, 1).Value * Cells(i, 5).Value
Cells(i, 11) = "Used-1"
ElseIf (Cells(i, .Value <> 0 And Cells(i, <> "") Then ' use percentage discount from col H - Discount %
' ------- This line gives an error --- trying to apply a percentage calculation
' Cells(i, 10).Value = Cells(i, 1).Value * (Cells(i, 5).Value - (Cells(i, 5).Value * Cells(i, .Value) / 100)
Cells(i, 11) = "Used-2"
Else
Cells(i, 11) = "Used-None" ' unknown condition
End If
End If
End If
If Cells(i, 1).Value = "Qty." Then bStart = True ' define start
Next
End Sub
---------------------------