Consulting

Results 1 to 4 of 4

Thread: Looping through a column

  1. #1
    VBAX Newbie
    Joined
    Sep 2008
    Posts
    2
    Location

    Looping through a column

    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?

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Menu Tools>Data>Filter>Advanced Filter and there is an option to list unique.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Newbie
    Joined
    Sep 2008
    Posts
    2
    Location
    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.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    With ActiveSheet

    .Range(.Range("B1"), .Range("B1").End(xlDown)).AdvancedFilter _
    Action:=xlFilterCopy, _
    CopyToRange:=.Range("H1"), _
    Unique:=True
    End With
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •