Consulting

Results 1 to 3 of 3

Thread: Solved: macro to list unique data in a column

  1. #1

    Solved: macro to list unique data in a column

    Hi guys,

    This thread was originally solved by members of this forum. Here is the link if it helps: http://www.vbaexpress.com/forum/showthread.php?t=20109


    Let me explain what this thing does. I have data in A, B, and C. These are financial products. For each product in each database, I would like to add up the Market Cap Percentage for the desired range. Now currently, this works but it only works when more than 1 product is listed. So, I can only perform this task when I have two or more products. On many occasions, I have only one product. How can the macro be modified so that it will work on one product as well as up to 25?

    [VBA]Sub FillRanges()
    Columns("A:A").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
    "IV1"), Unique:=True
    Range(Cells(2, "IV"), Cells(2, "IV").End(xlDown)).Copy
    Range("H17").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=True
    Range(Cells(1, "IV"), Cells(1, "IV").End(xlDown)).ClearContents
    End Sub
    [/VBA]

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Is this what you want?

    [vba]
    Sub FillRanges()
    Columns("A:A").AdvancedFilter Action:=xlFilterCopy, CopyToRange:=Range( _
    "IV1"), Unique:=True
    If Range("IV3").Value = "" Then

    Range("IV2").Copy
    Else
    Range(Cells(2, "IV"), Cells(2, "IV").End(xlDown)).Copy
    End If
    Range("H17").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=True
    Range(Cells(1, "IV"), Cells(1, "IV").End(xlDown)).ClearContents
    End Sub
    [/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

  3. #3
    Works absolutely great. I gave it some quick tests.

    I should probably take that class online with you guys. I am most likely going to sign up.

Posting Permissions

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