Into tab "setting" I have sheets list generated automatically:
Column format: sheets with format A looks the same, contains only diffrent values and all with format B looks also the same, contains once again diffrent values .
Now I'm adding values to combobox:
Dim db_rows As Long, i As Long
Dim wbs As Workbook
Dim wss As Worksheet
Set wbs = ActiveWorkbook
Set wss = wbs.Worksheets("setting")
db_rows = wss.Cells(Rows.Count, 1).End(xlUp).Row
With cb3
.Clear
For i = 2 To db_rows
If wss.Cells(i, 1).Value <> "" Then
.AddItem wss.Cells(i, 2).Value
End If
Next i
End With
Me.cb3.ListIndex = 0
Then I want to populate listBox2 based on value clicked on cb3. But below code is working that same for all format.
Dim NameArray As Variant
With Sheets(Me.cb3.Value)
NameArray = .Range(.Range("B6"), .Range("B6").End(xlDown))
NameArray = .Range("A8:H100")
End With
listBox2.List = NameArray
Please help.
Example of diffrent ranges, based on Format:
Format A: Range: A8:H100
Format B: Range: B10:G50
Format C: Range: C20:B30 etc....
I did as below:
But if you know how can I do it better or into diffrent way please share the idea with me.