ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filtering in VBA (https://www.excelbanter.com/excel-programming/321338-filtering-vba.html)

Alan L. Wagoner

Filtering in VBA
 
I have a column of values starting in A2, Sheet 1. These values repeat and
are not unique. I want column B2 to have a single occurrence of each cell
in column A.

As an example, here's what I'm looking for:

Sheet1:
Col A Col B
============
brown brown
blue blue
black black
orange orange
black red
black
brown
blue
blue
red
blue

Thanks in advance,

Alan L. Wagoner



Chip[_3_]

Filtering in VBA
 
you know you can use the built in filter function in excel, and then
you wouldnt need to use vba?


Alan L. Wagoner

Filtering in VBA
 
Yeah, I know, but I need to programmatically create those sheets, because I
have VBA code that will populate them. Right now, I have to manually create
them, and I'd rather have that process automated.

"Chip" wrote in message
oups.com...
you know you can use the built in filter function in excel, and then
you wouldnt need to use vba?




Bob Phillips[_6_]

Filtering in VBA
 
Alan,

Very simple using built-in functionality

Columns("A:A").AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range("B1"), _
Unique:=True

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alan L. Wagoner" wrote in message
...
I have a column of values starting in A2, Sheet 1. These values repeat

and
are not unique. I want column B2 to have a single occurrence of each cell
in column A.

As an example, here's what I'm looking for:

Sheet1:
Col A Col B
============
brown brown
blue blue
black black
orange orange
black red
black
brown
blue
blue
red
blue

Thanks in advance,

Alan L. Wagoner





Chip[_3_]

Filtering in VBA
 
Note that with Bob's approach it repeats the first unique entry twice.


Bob Phillips[_6_]

Filtering in VBA
 
Not if he has headings, which he should do <g

Bob

"Chip" wrote in message
ups.com...
Note that with Bob's approach it repeats the first unique entry twice.




Alan L. Wagoner

Filtering in VBA
 
Bob,

You da Man! May your weekend be filled with fun, joy, and happiness.

Cheers! I owe you a pint.

--Alan

"Bob Phillips" wrote in message
...
Alan,

Very simple using built-in functionality

Columns("A:A").AdvancedFilter Action:=xlFilterCopy, _
CopyToRange:=Range("B1"), _
Unique:=True

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alan L. Wagoner" wrote in message
...
I have a column of values starting in A2, Sheet 1. These values repeat

and
are not unique. I want column B2 to have a single occurrence of each

cell
in column A.

As an example, here's what I'm looking for:

Sheet1:
Col A Col B
============
brown brown
blue blue
black black
orange orange
black red
black
brown
blue
blue
red
blue

Thanks in advance,

Alan L. Wagoner







Bob Phillips[_6_]

Filtering in VBA
 

"Alan L. Wagoner" wrote in message
...
Bob,

You da Man! May your weekend be filled with fun, joy, and happiness.

Cheers! I owe you a pint.


Pint of Director's please!




All times are GMT +1. The time now is 05:20 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com