Ferreira1456
New Member
- Joined
- Mar 20, 2018
- Messages
- 30
- Office Version
- 365
- Platform
- Windows
For some reason advanced filter unique do not working properly.
Could you please help me?
Please take at look on my Macro and show me where is the problem. One of the error is the very first one.
Public Sub CustomerList()
Dim rngData As Range
Dim lin As Long
Dim li As ListItem
Sheet1.Select
With Sheet1
Set rngData = .Range("B2:C" & .Range("B" & Rows.Count).End(xlUp).Row)
rngData.AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=.Range("AA1"), _
Unique:=True
lin = 1
Do While .Cells(lin, "AA") <> ""
Set li = UserFormCustomer.listvBetweenDates.ListItems.Add(Text:=" ")
li.ListSubItems.Add Text:=.Cells(lin, "AA").Value
li.ListSubItems.Add Text:=.Cells(lin, "AB").Value
lin = lin + 1
Loop
.Range("AA1:AB" & .Range("AA" & Rows.Count).End(xlUp).Row + 1).ClearContents
.Cells(1, 1).Activate
End With
Could you please help me?
Please take at look on my Macro and show me where is the problem. One of the error is the very first one.
Public Sub CustomerList()
Dim rngData As Range
Dim lin As Long
Dim li As ListItem
Sheet1.Select
With Sheet1
Set rngData = .Range("B2:C" & .Range("B" & Rows.Count).End(xlUp).Row)
rngData.AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=.Range("AA1"), _
Unique:=True
lin = 1
Do While .Cells(lin, "AA") <> ""
Set li = UserFormCustomer.listvBetweenDates.ListItems.Add(Text:=" ")
li.ListSubItems.Add Text:=.Cells(lin, "AA").Value
li.ListSubItems.Add Text:=.Cells(lin, "AB").Value
lin = lin + 1
Loop
.Range("AA1:AB" & .Range("AA" & Rows.Count).End(xlUp).Row + 1).ClearContents
.Cells(1, 1).Activate
End With