cgmojoco
Well-known Member
- Joined
- Jan 15, 2005
- Messages
- 699
Hi there-
Help...I am looking for a better solution working with columns in VBA.
Currently, I refer to columns by their letter or # in my VBA code.
For example:
I have a scenario where I have to work with a dynamic data source that scrambles columns around (column is not always in the same position on the spreadsheet). Currenct...Also, there may be missing columns or new columns that need to be recognized.
What I would like to do is refer to my columns by header name.
For example (PSUEDO CODE):
Would the best way to go about something like this be to create an array with column header names that I can run things against? How would this look?
(column headers are always in row 2)
Help...I am looking for a better solution working with columns in VBA.
Currently, I refer to columns by their letter or # in my VBA code.
For example:
Rich (BB code):
Columns("AW:AW").FormulaR1C1 = "=+RC[-8]"
I have a scenario where I have to work with a dynamic data source that scrambles columns around (column is not always in the same position on the spreadsheet). Currenct...Also, there may be missing columns or new columns that need to be recognized.
What I would like to do is refer to my columns by header name.
For example (PSUEDO CODE):
Rich (BB code):
If column ("MTD BUD") or ("MTD REV") do not exist Then
Goto ErrorHandler
Else
Columns("MTD REV").FormulaR1C1 = "=+RC[MTD BUD]"
End if
Would the best way to go about something like this be to create an array with column header names that I can run things against? How would this look?
(column headers are always in row 2)