Hi All,
I have a sheet that has circa 300 constants/variables that I'll use throughout various bits codes to look for specific entries and I'm unsure how best to approach it.
I want to define all 300 in one place, so I can then refer to them, but unsure if they would be better as variables, or constants.
E.g.
Variable1 = "Ant"
Variable2 = "Anteater"
...
Variable300 = "Zebra"
or
Constant1 = "Ant"
...
Constant2 = "Zebra"
Once I've defined them, I'll want a way to produce these as a list, but unsure how to call them
E.G.
Col.A (typed reference) Col.B(code to add the corresponding value in this column, based upon the text in Col.A)
Constant1 Ant
Constant2 Anteater
...
Constant300 Zebra
I've been trying the 'Public Const' way of defining them (in a module):
and the below code to pull the values, but alas, it doesn't work:
Any ideas on how I should best approach this, and how I can get it to populate a list of them all to a sheet (so I don't have to review in VBA & the list can be there for viewing etc)?
Many thanks,
Upex
I have a sheet that has circa 300 constants/variables that I'll use throughout various bits codes to look for specific entries and I'm unsure how best to approach it.
I want to define all 300 in one place, so I can then refer to them, but unsure if they would be better as variables, or constants.
E.g.
Variable1 = "Ant"
Variable2 = "Anteater"
...
Variable300 = "Zebra"
or
Constant1 = "Ant"
...
Constant2 = "Zebra"
Once I've defined them, I'll want a way to produce these as a list, but unsure how to call them
E.G.
Col.A (typed reference) Col.B(code to add the corresponding value in this column, based upon the text in Col.A)
Constant1 Ant
Constant2 Anteater
...
Constant300 Zebra
I've been trying the 'Public Const' way of defining them (in a module):
Code:
Public Const Constant1 = "Ant"
Public Const Constant2 = "Anteater"
Public Const Constant300 = "Zebra"
and the below code to pull the values, but alas, it doesn't work:
Code:
Sub Populate_Constant_List()
Dim intRowCount As Integer
Dim I As Integer
intRowCount = Range("a1").CurrentRegion.Rows.Count - 3
Range("b4").Select
For I = 1 To intRowCount
ActiveCell.Value = constant & I
ActiveCell.Offset(1, 0).Select
Next I
End Sub
Any ideas on how I should best approach this, and how I can get it to populate a list of them all to a sheet (so I don't have to review in VBA & the list can be there for viewing etc)?
Many thanks,
Upex