NumberCrunchingMonky
Technical User
i'm looking for some VBA code (rather, I found what looks like a pretty good starting point that needs some tweaking) that will return unique values from a list of duplicate values. Here's my example...
say, my lookup value is "xxxxx". I want to put "xxxxx" in the code to pull out all unique names associated with "xxxxx" in my data field (where "data field" is on sheet2 and I want the names returned on sheet1. The names adjacent to the codes are in a range named "Names".
Here's the code I found on this site thanks to Skp Vought:
sheet object code:
Private Sub Worksheet_Change(ByVal Target As Range)
MakeSelection Target
End Sub
module code:
Sub MakeSelection(Target As Range)
Set rng = Application.Intersect(Target, Range("StateInput"
)
If Not rng Is Nothing Then
Sheets("Sheet1"
.Cells(1, 1).CurrentRegion.Clear
With Sheets("Sheet4"
.Cells(1, 1)
.AutoFilter Field:=1, Criteria1:=Target.Value
.CurrentRegion.Copy Destination:=Sheets("Sheet1"
.Cells(1, 1)
End With
End If
End Sub
thank you.
monky
say, my lookup value is "xxxxx". I want to put "xxxxx" in the code to pull out all unique names associated with "xxxxx" in my data field (where "data field" is on sheet2 and I want the names returned on sheet1. The names adjacent to the codes are in a range named "Names".
Here's the code I found on this site thanks to Skp Vought:
sheet object code:
Private Sub Worksheet_Change(ByVal Target As Range)
MakeSelection Target
End Sub
module code:
Sub MakeSelection(Target As Range)
Set rng = Application.Intersect(Target, Range("StateInput"
If Not rng Is Nothing Then
Sheets("Sheet1"
With Sheets("Sheet4"
.AutoFilter Field:=1, Criteria1:=Target.Value
.CurrentRegion.Copy Destination:=Sheets("Sheet1"
End With
End If
End Sub
thank you.
monky