get unique records using advanced filter from VBA

macro_user

Board Regular
Joined
Mar 9, 2009
Messages
101
hi...
i need to use the advance filter=>unique records only feature from my macro... how would i do tat? i have 3 columns... column A has records which are repeated... column B and column C's values for a corresponding column A's value are the same...
A B C
a 3 6
b 4 7
c 8 9
d 1 2
a 3 6
b 4 7
.... and so on...
i need to use tat feature so tat i can filter column A alone and then copy column A, column B and column C's value to columns E,F and G...
kindly help me out on this...
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).

macro_user

Board Regular
Joined
Mar 9, 2009
Messages
101
wat i need is to get a unique value in column A with its corresponding values in column B and C... i do not mind if its using the in-built advanced filter option or its a piece of code... but i need to do this from my macro...
 

macro_user

Board Regular
Joined
Mar 9, 2009
Messages
101
hi...
i need to use the advance filter=>unique records only feature from my macro... how would i do tat? i have 3 columns... column A has records which are repeated... column B and column C's values for a corresponding column A's value are the same...
A B C
a 3 6
b 4 7
c 8 9
d 1 2
a 3 6
b 4 7
d 1 2
c 8 9
.... and so on...
i need to use tat feature so tat i can filter column A alone and then copy column A, column B and column C's value to columns E,F and G...
kindly help me out on this...

i need :
A B C
a 3 6
b 4 7
c 8 9
d 1 2... and so on...
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,282
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

The best way do get a start on the code would be to use the macro recorder when you do it manually.

I tried that and this is what I got.
Code:
    Range("A1:C9").AdvancedFilter Action:=xlFilterInPlace, Unique:=True
 
Last edited:

macro_user

Board Regular
Joined
Mar 9, 2009
Messages
101
The best way do get a start on the code would be to use tje macro recorder when you do it manually.

I tried that and this is what I got.
Code:
    Range("A1:C9").AdvancedFilter Action:=xlFilterInPlace, Unique:=True

yaa... actually i tried somethin like this... but i tried selecting only column A and doing advanced filter... then, column A gives unique values but when i try to copy column B and C, the corresponding values aren't getting copied... let me try selecting the entire range and then doing advanced filter... Thanks!
 

macro_user

Board Regular
Joined
Mar 9, 2009
Messages
101

ADVERTISEMENT

No... i just tried wat you said and it dint work... when i do Advanced Filter on after selecting columns A, B and C, i'm getting the proper values... but when i copy it and paste these 3 columns into the adjacent 3 columns, then im not getting the proper values.... its like the copy and paste is not proper... its missing few records in between... Has anyone had any such problem with Advanced filter?
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,282
Office Version
  1. 365
Platform
  1. Windows
why not use the Copy to another location option?:)
 

macro_user

Board Regular
Joined
Mar 9, 2009
Messages
101
i need to do advanced filter on columns A,B and C and paste them in another location in the same worksheet... maybe columns H,I and J... is this what you asked me? if so, how do i do tat? if not, can you phrase it a little clearly? Thanks
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,282
Office Version
  1. 365
Platform
  1. Windows
The first option when you goto Advanced Filter is Copy to another location.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,593
Messages
5,637,294
Members
416,963
Latest member
zazama

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
Top