Darth_Sullivan
New Member
- Joined
- Oct 23, 2013
- Messages
- 48
I've seen posts about copying and pasting data filtered for uniques before. I found one that does almost exactly what I need it to do. Current code searches all my sheets through column A for all unique values and presents them to me on the sheet with my command button. What I need it tweaked for, is i need it to bring the contents of column B that corresponds to the unique number from A.
More simply stated: Column A across many different sheets contains a customer ID number unique to them.
Column B contains their name.
Each row represents a transaction with said customer.
I am trying to create a sheet that will show each customer with their name to essentially have just a directory of names and ID numbers.
Current code just brings and sorts my ID numbers...
Any help is much appreciated. I've just simply been unable to decipher what I need to tell vba to do...
Thank you for your time.
More simply stated: Column A across many different sheets contains a customer ID number unique to them.
Column B contains their name.
Each row represents a transaction with said customer.
I am trying to create a sheet that will show each customer with their name to essentially have just a directory of names and ID numbers.
Current code just brings and sorts my ID numbers...
Code:
Sub UniqueValues()
Dim newWS As Worksheet, r As Long, N As Long, i As Integer
Application.ScreenUpdating = False
N = 1
For i = 2 To Sheets.Count - 2
r = Sheets(i).Cells(Rows.Count, "A").End(xlUp).Row
Sheets(i).Range("A2:A" & r).Copy
Cells(N, 1).PasteSpecial xlValues
N = Cells(Rows.Count, "A").End(xlUp).Row + 1
Next
r = Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:A" & r).AdvancedFilter _
Action:=xlFilterInPlace, Unique:=True
Range("A2:A" & r).Copy
Range("B2").PasteSpecial xlValues
Application.CutCopyMode = False
Range("A2:A" & r).AdvancedFilter _
Action:=xlFilterInPlace, Unique:=False
Columns(1).Delete
r = Cells(Rows.Count, "A").End(xlUp).Row
Range("A2:A" & r).Sort key1:=Range("A2"), header:=xlNo
Application.ScreenUpdating = True
End Sub
Private Sub CommandButton1_Click()
Sheets("Players").UniqueValues
End Sub
Any help is much appreciated. I've just simply been unable to decipher what I need to tell vba to do...
Thank you for your time.