
Option Explicit
Private Sub UserForm_Initialize()
ListBox1.RowSource = ""
Range("A1").AutoFilter
End Sub
Private Sub TextBox1_Change()
Dim rng1 As Range
On Error GoTo clear_list
ListBox1.Clear
Range("a1").CurrentRegion.AutoFilter field:=2, Criteria1:=TextBox1 & "*"
Set rng1 = Range(Split(Range("a1").CurrentRegion.SpecialCells(xlCellTypeVisible).Address, ",")(1))
ListBox1.List = rng1.Columns(2).Value
Exit Sub
clear_list:
ListBox1.Clear
Resume Next
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
Range("A1").AutoFilter
End Sub
|
ListBox1.ColumnCount = 3
ListBox1.List = rng1.Value 'al posto di
'ListBox1.List = rng1.Columns(2).Value
'tutto il blocco seguente:
If rng1.Columns(1).Cells.Count = 1 Then
ListBox1.AddItem rng1.Columns(2).Value
Else
ListBox1.List = rng1.Columns(2).Value
End If |
| scossa's web site |
| Se tu hai una mela, ed io ho una mela, e ce le scambiamo, allora tu ed io abbiamo sempre una mela per uno. Ma se tu hai un'idea, ed io ho un'idea, e ce le scambiamo, allora abbiamo entrambi due idee. (George Bernard Shaw) |
Range("a1").CurrentRegion.AutoFilter field:=2, Criteria1:=TextBox1 & "*" |
