Ferreira1456
New Member
- Joined
- Mar 20, 2018
- Messages
- 30
- Office Version
- 365
- Platform
- Windows
I have a form with a ListBox. Which is filled in when I open the form.
I'm using the following code:
Private Sub UserForm_Initialize()
Dim last_Row As Long
last_Row = Application.WorksheetFunction.CountA(sh.Range("A:A"))
With Me.ListBox1
.ColumnHeads = True
.ColumnCount = 61
.ColumnWidths = "20,40,60,0,50,120,0,0,0,0,0,120,120,0,0,0,0,0,0,0,0,0,0,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
If last_Row = 1 Then
.RowSource = "Customers!A2:BI2"
Else
.RowSource = "Customers!A2:BI" & last_Row
End If
End With
End Sub
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I have a button to do the Filter with this code::
Private Sub cmdSearch_Click()
Dim sh As Worksheet
Set sh = Sheets("Customers")
sh.Select
sh.Range("$A$1:$BI$270000").AutoFilter Field:=6, Criteria1:="=*" & Me.txtSearchByName.Value & "*"
sh.Range("$A$1:$BI$270000").AutoFilter Field:=24, Criteria1:="=*" & Me.txtSearchByStatus.Value & "*"
End Sub
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I have the third button to clean the filter.
Private Sub cmd CleanFilter_Click()
ActiveSheet.ShowAllData
End Sub
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
From here, I need your help. When the filter is ready. I need the same listBox to be filled with the filter.
Also, I need that when I double-click the ListBox line, all TextBox and ComboBox are filled.
The column where the filter is made is column “F”.
Thank you very much.
I'm using the following code:
Private Sub UserForm_Initialize()
Dim last_Row As Long
last_Row = Application.WorksheetFunction.CountA(sh.Range("A:A"))
With Me.ListBox1
.ColumnHeads = True
.ColumnCount = 61
.ColumnWidths = "20,40,60,0,50,120,0,0,0,0,0,120,120,0,0,0,0,0,0,0,0,0,0,40,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
If last_Row = 1 Then
.RowSource = "Customers!A2:BI2"
Else
.RowSource = "Customers!A2:BI" & last_Row
End If
End With
End Sub
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I have a button to do the Filter with this code::
Private Sub cmdSearch_Click()
Dim sh As Worksheet
Set sh = Sheets("Customers")
sh.Select
sh.Range("$A$1:$BI$270000").AutoFilter Field:=6, Criteria1:="=*" & Me.txtSearchByName.Value & "*"
sh.Range("$A$1:$BI$270000").AutoFilter Field:=24, Criteria1:="=*" & Me.txtSearchByStatus.Value & "*"
End Sub
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
I have the third button to clean the filter.
Private Sub cmd CleanFilter_Click()
ActiveSheet.ShowAllData
End Sub
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
From here, I need your help. When the filter is ready. I need the same listBox to be filled with the filter.
Also, I need that when I double-click the ListBox line, all TextBox and ComboBox are filled.
The column where the filter is made is column “F”.
Thank you very much.