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: 106
Default Best Practice for Public Variables for Column Headings

I have a spreadsheet that consists of 2 tabs with around 35 columns and 20 columns respectively. Throughout the code I am updating fields in the column. The developer that originally created the spreadsheet uses the actual column number in the code reference when updating a field which makes it difficult to know which field you're updating when you're looking at the code.. Is there a best practice around this? What I would like to do is create public variables that contain meaningful names with the column number indicated there and use the variable name throughout the code when a field is updated. For example:

Declare the following as public variables:
SHEET1_FirstName = 1 'column number for FirstName column on SHEET1
SHEET1_LastName = 2 'column number for LastName column on SHEET1

I can then use the variables when I need to make an update:

Sheets("SHEET1").Cells(l_Row, SHEET1_FirstName)

Is there a best practice around this and how much overhead is added by using this convention? This makes it easier to add or remove columns as well.

Thanks.
 
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
Public Variables Richard Excel Programming 5 April 9th 10 11:23 AM
Public Variables Richard Excel Programming 4 July 3rd 08 02:38 PM
Public variables Tomski[_28_] Excel Programming 3 August 10th 06 03:19 PM
Public Variables [email protected] Excel Programming 1 September 1st 05 04:14 PM
Public Variables Les Gordon Excel Programming 2 November 11th 04 12:29 PM


All times are GMT +1. The time now is 02:06 PM.

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"