LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Keeping code dynamic when adding columns to a list of records

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.

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to delete all duplicate records - without keeping one of them Aviva B Excel Worksheet Functions 5 December 8th 09 02:59 PM
Offset code for dynamic row# & multiple columns in LINEST function RJ Excel Worksheet Functions 3 May 29th 07 06:29 PM
Adding columns w/new formulas BUT keeping subtotals Exceldawg Excel Discussion (Misc queries) 0 April 19th 06 02:58 PM
Preventing duplicates when adding records to list bobwilson[_8_] Excel Programming 1 April 2nd 06 01:21 AM
Pivot table: Adding dynamic columns Kobayashi[_34_] Excel Programming 0 February 19th 04 04:45 PM


All times are GMT +1. The time now is 04:19 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"