Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: Check for Zero or Blank field value

  1. #1
    Board Regular
    Join Date
    Apr 2002
    Location
    South Bend, IN
    Posts
    996
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    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

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

  2. #2
    Board Regular
    Join Date
    Apr 2002
    Location
    South Bend, IN
    Posts
    996
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    The special character is the number 8
    Do not know why the funkie display

  3. #3
    Board Regular
    Join Date
    Apr 2002
    Location
    Greenwood, SC
    Posts
    677
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Just replied to your private message.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •