Quote Originally Posted by p45cal View Post
I haven't.
I took out Option Explicit.
If you must define them:
Dim xx,yy,zz
in the same Listbox_Click sub.
I would like to add one listbox with just opportunity to choose rebar
What am I doing wrong in code, that it gives me error
Public Sub UserChoice()
Dim WS As Worksheet
    Dim lb2 As MSForms.ListBox
    Set WS = ThisWorkbook.Worksheets("Sheet1")
    Set lb2 = WS.OLEObjects("ListBox2").Object
    lb2.Clear
    WS.Range("E20").Resize(, 6).ClearContents
    Dim rebars2 As Scripting.Dictionary
    Set rebars2 = New Scripting.Dictionary
   
    ' 2 rebars
    rebars2.Add "2x6", 0.57
    rebars2.Add "2x8", 1.01
    rebars2.Add "2x10", 1.57
    rebars2.Add "2x12", 2.26
    rebars2.Add "2x14", 3.08
    rebars2.Add "2x16", 4.02
    rebars2.Add "2x18", 5.09
    rebars2.Add "2x20", 6.28
    rebars2.Add "2x22", 7.6
    rebars2.Add "2x25", 9.82
    rebars2.Add "2x28", 12.32
    rebars2.Add "2x32", 16.08
    rebars2.Add "2x36", 20.36
    rebars2.Add "2x40", 25.13
    
    
    
    For i = 0 To rebars2.Count - 1
        lb2.AddItem rebars2.Items(i) & " - " & rebars2.Keys(i)
        
    Next i
    
    




End Sub
error3.jpg