Advanced filter unique do not working properly.

Ferreira1456

New Member
Joined
Mar 20, 2018
Messages
30
Office Version
  1. 365
Platform
  1. Windows
For some reason advanced filter unique do not working properly.
rsp-content-status-subscribed.png


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
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Please take at look on my Macro and show me where is the problem. One of the error is the very first one.
I guess you already run the macro, so why don't you tell what happens and what went wrong with respect to your expectations?

Bye
 
Upvote 0
Cross posted https://answers.microsoft.com/en-us...e-do-not/4a07e969-de9e-4336-b1e8-add4c30174ad

Cross-Posting
While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
For some reason it is not doing the filter (unique). Some records continue to appear. The first record is one of the repeats.
 
Upvote 0
Do your columns have a header? Anyway, row 1 will be considered a header, and thus will "seem" duplicated.
 
Upvote 0
Thank you for your help.

This line of code removed the duplication of the first.
But, show the header, which I do not want it to appear.
Also, another record keeps repeating.
 
Upvote 0
Thank you for your help.

This line of code removed the duplication of the first.
But, show the header, which I do not want it to appear.
Also, another record keeps repeating.
Believe me, Excel don't fail... So you have to search wich is the small difference between the two rows that "look" duplicated; may be a trailing space; or (if you rework calculated numbers) a small difference of 0.000000000001

Advanced filter copy the headers; if you don't like them you have to clear that line after the advanced filtering.

Bye
 
Upvote 0
Hi Anthony47. Thank you very much for your help.
like you said,Excel don't fail... So The only thing I need on the entire line is columns B and C are exactly the same
The others column are different between the two rows.
 
Upvote 0

Forum statistics

Threads
1,214,571
Messages
6,120,302
Members
448,954
Latest member
EmmeEnne1979

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top