Skip to content

Instantly share code, notes, and snippets.

@stevesohcot
Last active June 19, 2023 14:54
Show Gist options
  • Save stevesohcot/76ad8bbaac09a0ee02fc95c3d8c339f3 to your computer and use it in GitHub Desktop.
Save stevesohcot/76ad8bbaac09a0ee02fc95c3d8c339f3 to your computer and use it in GitHub Desktop.
Excel VBA - validate column headers
Const COL_FIRST_NAME = "A"
Const ROW_HEADER = "2"
Dim validation As Boolean
validation = validateColHeaders()
If validation = False Then
End
End If
Public Function validateColHeaders() As Boolean
Dim okToProceed As Boolean
okToProceed = True
If Worksheets("import").Range(COL_FIRST_NAME & ROW_HEADER).FormulaR1C1 <> "firstName" Then
MsgBox "Column 'firstName' not found where expected"
okToProceed = False
End If
validateColHeaders = okToProceed
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment