PDA

View Full Version : Looping through a column



Cidolfus
09-23-2008, 10:44 PM
Hello,

I have a spreadsheet with lots of rows (40000+), and in the 2nd column of this spreadsheet, it consists of an organization's department, so the 2nd column would look something like this:

Sales
Sales
Sales
Finance
Sales
Finance
HR
HR
HR
Sales

etc...

What I'd like is to loop through this column, and be returned with all the departments - Sales, Finance, HR. (Something like dinstinct in PL/SQL)

How can I do something like that?

Bob Phillips
09-24-2008, 12:45 AM
Menu Tools>Data>Filter>Advanced Filter and there is an option to list unique.

Cidolfus
09-24-2008, 03:41 AM
Hello,

Thank you for your reply.

Is there a way to do this programmatically? As I need to format these data further. The returning of the unique data is just the first step of many to come.

Thank you.

Bob Phillips
09-24-2008, 04:04 AM
With ActiveSheet

.Range(.Range("B1"), .Range("B1").End(xlDown)).AdvancedFilter _
Action:=xlFilterCopy, _
CopyToRange:=.Range("H1"), _
Unique:=True
End With