It's an unusual way of doing it - the worksheet is a PERFECT place for storing a 2 dimensional array of values, such as your bracket list, with corresponding widths.
If you insist, though, then I'd store your master data in a couple of constants. So, in a standard module, enter the following:
Option Explicit
Public Const sBracketArray As String = "BRCKT016|BRCKT148|BRCKT001|BRCKT002|BRCKT003|BRCKT004|BRCKT027|BRCKT028|BRCKT029|BRCKT040|BRCKT067|BRCKT235|BRCKT236|BRCKT237|BRCKT242|BRCKT245|530133.001|530133.002|BRCKT030|BRCKT031|BRCKT032|BRCKT208|BRCKT034|BRCKT046|BRCKT148|BRCKT001|BRCKT002|BRCKT003|BRCKT004|BRCKT027|BRCKT028|C04014|BRCKT040|BRCKT067|BRCKT235|BRCKT236|BRCKT237|BRCKT242|BRCKT245|BRCKT247|530133.001|530133.002|BRCKT030|BRCKT031|BRCKT032|BRCKT033|BRCKT042|BRCKT053|BRCKT058|BRCKT202|BRCKT221|BRCKT217|BRCKT234|BRCKT195|BRCKT197|530133.003|C03016|C04014|BRCKT020|C03015|BRCKT016|BRCKT035|BRCKT233|C04015|C04019|C04032|C04033|C04035|C04056|C04069|BRCKT057|BRCKT161|BRCKT162|BRCKT163|BRCKT174|BRCKT209|C05001|C05016|C05046|C05047|C05050|C05051|BRCKT044|BRCKT187|BRCKT208|BRCKT228|C07010"
Public Const sWidthArray As String = "55|50|56|56|51|51|50|50|50|20|60|50|53.5|60|35|34|50|50|55|55|51|63|51|50|50|56|56|51|51|50|50|50|20|60|50|53.5|60|35|34|40|50|60|55|55|51|51|50|55|50|56|68|80|55|63.5|63.5|60|50|50|52.5|52.5|54.5|60|54.5|60|55|60|60|60|55|60|54.5|62|62|62|60|63|60|60|58|60|60|60|63|63|63|60|63.5"
Sub Button1_Click()
UserForm1.Show
End Sub
Then in your userform module, enter:
Option Explicit
Private Sub CancelButton_Click()
Unload Me
End Sub
Private Sub OKButton_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
Dim i As Integer
Dim s() As String
s = Split(sBracketArray, "|")
With Worksheets("Data")
For i = LBound(s) To UBound(s)
Me.ComboBox1.AddItem s(i)
Next i
End With
End Sub
Private Sub ComboBox1_Change()
Me.TextBox2.Value = Abs(Me.TextBox1.Value - GetWidth(Me.ComboBox1.Value) - 10)
End Sub
Function GetWidth(ByVal sBracket As String)
Dim i As Integer
Dim sB() As String
Dim sW() As String
sB = Split(sBracketArray, "|")
sW = Split(sWidthArray, "|")
For i = LBound(sB) To UBound(sB)
If sB(i) = sBracket Then
GetWidth = CDbl(sW(i))
Exit Function
End If
Next i
End Function
See attachment for a worked example.
Bookmarks