Hi
I have this code is designed by DanteAmore.
it will populate data for column A,B and the column contains date in header with match selected date from combobox1
the column date will contains numeric values.
now I add combobox2 contains three condition (not zero, zero, unknown)
when select date from combobox1 will populate data after matching the date is in header in row1 and when select not zero from combobox2 then will populate data except containing zero in column(3) in listbox . when select date from combobox1 will populate data after matching the date is in header in row1 , when select zero from combobox2 then will populate data except containing not zero in column(3) in listbox . when select date from combobox1 will populate data after matching the date is in header in row1 , when select unknown from combobox2 then will populate data for all of values without any exception .
I have this code is designed by DanteAmore.
it will populate data for column A,B and the column contains date in header with match selected date from combobox1
the column date will contains numeric values.
now I add combobox2 contains three condition (not zero, zero, unknown)
when select date from combobox1 will populate data after matching the date is in header in row1 and when select not zero from combobox2 then will populate data except containing zero in column(3) in listbox . when select date from combobox1 will populate data after matching the date is in header in row1 , when select zero from combobox2 then will populate data except containing not zero in column(3) in listbox . when select date from combobox1 will populate data after matching the date is in header in row1 , when select unknown from combobox2 then will populate data for all of values without any exception .
VBA Code:
Private Sub ComboBox1_Change()
Dim j As Long
Dim wds As String
With ComboBox1
If .ListIndex = -1 Then Exit Sub
For j = 2 To ListBox1.ColumnCount - 1
wds = wds & IIf(j = .ListIndex + 1, ";", "0;")
Next
ListBox1.ColumnWidths = ";;" & wds
End With
End Sub
Private Sub UserForm_Activate()
Dim lr As Long, lc As Long, j As Long
Dim wds As String
lc = Cells(1, Columns.Count).End(1).Column
lr = Range("A" & Rows.Count).End(3).Row
ComboBox1.List = Application.Transpose(Range("D1", Cells(1, lc)).Value)
With ListBox1
.ColumnCount = lc
.List = Range("A2", Cells(lr, lc)).Value
For j = 0 To ListBox1.ColumnCount - 1
wds = wds & "0;"
Next
.ColumnWidths = wds
End With
End Sub