I'm writing a macro to automate the formatting of certain cell ranges. In order to make it as versatile as possible, I would like to make some of the formatting decisions at runtime by entering strings.
Currently I use a select-case-statement, which seems very tedious to me.
Dim strInput As String
strInput = "xlDashDotDot"
Dim nConstVal As Integer
Select Case strInput
Case "xlContinuous"
nConstVal = xlContinuous
Case "xlDash"
nConstVal = xlDash
Case "xlDashDot"
nConstVal = xlDashDot
Case "xlDashDotDot"
nConstVal = xlDashDotDot
Case "xlDot"
nConstVal = xlDot
Case "xlDouble"
nConstVal = xlDouble
Case "xlLineStyleNone"
nConstVal = xlLineStyleNone
Case "xlSlantDashDot"
nConstVal = xlSlantDashDot
End Select
[...]
rng.Borders.LineStyle = nConstVal
Is there a function that takes the name of a build-in constant and returns the corresponding value?
Dim strInput As String
strInput = "xlDashDotDot"
Dim nConstVal As Integer
nConstVal = GetConstVal(strInput)