Originally Posted by
mdmackillop
Try
[vba]
Private Sub CommandButton1_Click()
Dim i As Long, Crit As Long
Dim f As Boolean
If Not ActiveSheet.Filtermode Then ActiveSheet.ShowAllData
For i = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(i) Then
f = True
If IsNumeric(Me.ListBox1.List(i)) Then
Cells(1, 9) = "Year"
Cells(2, 9) = Me.ListBox1.List(i)
Else
Cells(1, 10) = "Brand"
Cells(2, 10) = Me.ListBox1.List(i)
End If
End If
Next
If Not f Then
MsgBox "Select items to filter"
Exit Sub
End If
Range("Database").AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
Range("CritRange"), Unique:=False
Range("CritRange").ClearContents
End Sub
[/vba]
and
CritRange =OFFSET(Foglio1!$I$1,0,0,COUNTA(Foglio1!$I:$I),COUNTA(Foglio1!$1:$1)-6)