C
cwrm4
Looking for advice on a "best practice" with Excel VBA:
I have a spreadsheet for customer master data records with about 30
columns. I have some simple userforms that enable the user to add/edit/
view records from the worksheet with the master data. The user does
not have access to the master data worksheet as I need to force the
data they enter to go through several validations prior to writing/
updating a record.
Right now to add/update a record (and fill in fields on the userform)
I have the column numbers hardcoded via public constants. Works great
for now...but, if in the future I want to add a column (say, insert a
country column after state), my column numbers will get "out-of-
whack".
What would be the best way to keep the spreadsheet and code dynamic in
terms of adding future columns (in between existing columns)? Should I
just, as an initialization event, search for the heading (e.g.
"phone") for each column and then assign the column numbers to global
variables? Do I just stick a bunch of "future use" columns in the
spreadsheet? Any guidance would be appreciated.
I have a spreadsheet for customer master data records with about 30
columns. I have some simple userforms that enable the user to add/edit/
view records from the worksheet with the master data. The user does
not have access to the master data worksheet as I need to force the
data they enter to go through several validations prior to writing/
updating a record.
Right now to add/update a record (and fill in fields on the userform)
I have the column numbers hardcoded via public constants. Works great
for now...but, if in the future I want to add a column (say, insert a
country column after state), my column numbers will get "out-of-
whack".
What would be the best way to keep the spreadsheet and code dynamic in
terms of adding future columns (in between existing columns)? Should I
just, as an initialization event, search for the heading (e.g.
"phone") for each column and then assign the column numbers to global
variables? Do I just stick a bunch of "future use" columns in the
spreadsheet? Any guidance would be appreciated.