PDA

View Full Version : Solved: macro to list unique data in a column



joeyc
07-03-2008, 07:13 PM
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?

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

Bob Phillips
07-04-2008, 01:03 AM
Is this what you want?


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

joeyc
07-04-2008, 06:05 AM
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. :beerchug: