I am trying to format a given range . The BorderStyle property of a class in the code below has “xlMedium” as value which is of string data type, but weight property needs xlMedium as a constant , how do I convert this string value into a constant ?
Thank you.
Function applyFormat(ByRef objRng As clsRange)
' Select the Range
Worksheets(objRng.SheetName).Select
Worksheets(objRng.SheetName).Range(objRng.RangeValue).Select
With Selection.Borders(xlInsideVertical)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = (Me.BorderStyle)
End With
With Selection.Borders(xlInsideHorizontal)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = (Me.BorderStyle)
End With
End Function
There is no simple way to convert from a string to its equivalent enum member.
You should change to
BorderStyle as XlBorderWeightand use the explicit integer values, if you don’t you would need to lookup each member manually;