开发者

Required field handling Excel VBA

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 wri开发者_StackOverflow社区te the tons of IFs that I will need. Is there a more efficient way to do it?


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜