tags:

views:

17

answers:

1

Hi everyone, I have an application I have created in Excel VBA. This application requires a lot of entries from the user. All the fields/cells are required to have values before submission. What will be the best way to check that the users entered values in every single field/cell. I could do simple IF satatements, but that will take forever to write the tons of IFs that I will need. Is there a more efficient way to do it?

A: 

You will need to use if statements. You can speed the process up by creating a helper function. This one checks for empty and numeric data only. It can be modified to look for dates and text easily

Function ValidCell(RowPos As Long, ColPos As Long) As Boolean
    Dim ws As Worksheet
    Dim v As Variant

    Set ws = ActiveSheet
    v = ws.Cells(RowPos, Colpos).Value

    If IsEmpty(v) Or Not IsNumeric(v) Then
        ValidCell = False
    Else
        ValidCell = True
    End If
End Function
bugtussle