Last active
June 19, 2023 14:54
-
-
Save stevesohcot/76ad8bbaac09a0ee02fc95c3d8c339f3 to your computer and use it in GitHub Desktop.
Excel VBA - validate column headers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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