inactiveUser214710
Board Regular
- Joined
- Apr 27, 2012
- Messages
- 171
Hi every one
I have a userform that has a combobox (combobox1) to choose a specific month and a command button to show all months data in just one listbox(Listbox1). Data combobox1(UserForm_Initialize).
when I choose a month the list box shows the especif month data, but when I click command button the listbox show all the data of all months. This is my goal.
But I have a problem thal is, when I query the form with the sheet 2 open, it works well, but, if the query is made with the sheet 1 open, it don't work well.
That combobox, the data cames from sheet1, but the choose comes from filter in advence data, in sheet 2.
I think the resolution coud be simple but, at the moment, it does not occur to me the change I will have to make. I have no experience in vba reason why I ask for your help. Thank you.
Jdcar
I have a userform that has a combobox (combobox1) to choose a specific month and a command button to show all months data in just one listbox(Listbox1). Data combobox1(UserForm_Initialize).
when I choose a month the list box shows the especif month data, but when I click command button the listbox show all the data of all months. This is my goal.
But I have a problem thal is, when I query the form with the sheet 2 open, it works well, but, if the query is made with the sheet 1 open, it don't work well.
That combobox, the data cames from sheet1, but the choose comes from filter in advence data, in sheet 2.
I think the resolution coud be simple but, at the moment, it does not occur to me the change I will have to make. I have no experience in vba reason why I ask for your help. Thank you.
Jdcar
VBA Code:
Private Sub ComboBox1_Change()
'Choose month
Dim i As Integer
Dim Database(1 To 10000, 1 To 7)
Dim My_range As Integer
Dim colum As Byte
On Error Resume Next
ListBox1.ColumnCount = 7
ListBox1.RowSource = "a2:g10000"
'Sheet2 advence data
Sheet2.Range("j2").Value = ComboBox1.Value
Sheets("Sheet1").Range("A1:G10000").AdvancedFilter Action:=xlFilterCopy, _
CriteriaRange:=Range("j1:j2"), CopyToRange:=Sheets("Sheet2").Range("a1:g1"), Unique:=False
End Sub
Private Sub CommandButton1_Click()
'show data
ComboBox1.Value = Clear
On Error Resume Next
UserForm1.ListBox1.ColumnCount = 7
UserForm1.ListBox1.RowSource = "a2:g10000"
End Sub