Dim Matrice()
Private Sub ComboBox1_Change()
Dim Testo As String
Dim iTesto As Variant
Dim i As Long
ListBox1.Clear
For i = 1 To UBound(Matrice)
If Matrice(i, 1) = ComboBox1 Then
Testo = Testo & " " & i
End If
Next
Testo = Trim(Testo)
iTesto = Split(Testo)
Matrix = Application.Index(Matrice, Application.Transpose(iTesto), Array(1, 2, 3))
ListBox1.List = Matrix
End Sub
Private Sub CommandButton1_Click()
Dim uRiga As Long
Dim i As Long, j As Long
uRiga = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To uRiga
For j = 0 To ListBox1.ListCount - 1
If ListBox1.List(j, 0) = Foglio1.Cells(i, 2) And _
ListBox1.List(j, 1) = Foglio1.Cells(i, 3) And _
ListBox1.List(j, 2) = Foglio1.Cells(i, 4) Then
Foglio1.Cells(i, 7) = ComboBox2.Value
Foglio1.Cells(i, 8) = TextBox1.Value
End If
Next
Next
End Sub
Private Sub UserForm_Initialize()
Dim Intervallo As Range
Dim Righe, Colonne, r, C
With Range("A1").CurrentRegion
Righe = .Rows.Count - 1
Colonne = 3 '.Columns.Count
End With
Set Intervallo = Range("B2").Resize(Righe, Colonne)
ReDim Matrice(1 To Righe, 1 To Colonne)
For r = 1 To Righe
For C = 1 To Colonne
Matrice(r, C) = Intervallo.Cells(r, C)
Next
Next
'Matrice = Intervallo 'metodo più rapido
With ListBox1
.ColumnCount = 4
.BoundColumn = 2
.List() = Matrice
End With
ComboBox1.List = Array("1.1", "1.3", "2.1")
ComboBox2.List = Array("APERTO", "CHIUSO")
ListBox1.MultiSelect = fmMultiSelectMulti
End Sub |