Check for Zero or Blank field value

UHsoccer

Well-known Member
Joined
Apr 3, 2002
Messages
1,023
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, :cool:.Value = 0 Or Cells(i, :cool:.Value = "") Then

Cells(i, 10).Value = Cells(i, 1).Value * Cells(i, 5).Value
Cells(i, 11) = "Used-1"

ElseIf (Cells(i, :cool:.Value <> 0 And Cells(i, :cool: <> "") 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, :cool:.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

---------------------------
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,214,805
Messages
6,121,664
Members
449,045
Latest member
Marcus05

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top