Hello,
Is it possible to convert a Constant Name (string value) to its Constant Value (Long value)?
For example, in my following test code, I want to use the Horizontal Alignment value of xlCenter. The values are in an array, along with other settings for a given column. VBA will not accept "xlCenter" as a String value from my array.
I didn't find anything promising online, so in the meantime, I'm using a Select Case as a workaround… although I'm concerned how this will be a viable solution for a variety of other use cases where a Constant Name can't be used as a String Value. The only other thing I can think of is to store both Name and its Value in the Table that I'm using for my Settings Array.
Any advice or tips would be greatly appreciated...
Thank you...
Is it possible to convert a Constant Name (string value) to its Constant Value (Long value)?

For example, in my following test code, I want to use the Horizontal Alignment value of xlCenter. The values are in an array, along with other settings for a given column. VBA will not accept "xlCenter" as a String value from my array.
I didn't find anything promising online, so in the meantime, I'm using a Select Case as a workaround… although I'm concerned how this will be a viable solution for a variety of other use cases where a Constant Name can't be used as a String Value. The only other thing I can think of is to store both Name and its Value in the Table that I'm using for my Settings Array.
Any advice or tips would be greatly appreciated...
VBA Code:
Dim CValue as Long
For i = LBound(arrSettings) To UBound(arrSettings)
'Convert Constant Name to Value
Select Case arrSettings(i, 5)
Case "xlCenter"
CValue = -4108
Case "xlGeneral"
CValue = 1
Case Else
End Select
'Column Width
wsLogs.Columns(i).ColumnWidth = arrSettings(i, 4)
wsLogs.Columns(i).EntireColumn.HorizontalAlignment = CValue
Next i
Thank you...