Hello:
Please refer to attached file.
I have names in column B in Sheet1 as shown.
I need VB code to get the UNIQUE Names from this data and in Alphabettically order paste at A5 sheet2.
Let me know if you have any questions.
Thanks.
Riz
Hello:
Please refer to attached file.
I have names in column B in Sheet1 as shown.
I need VB code to get the UNIQUE Names from this data and in Alphabettically order paste at A5 sheet2.
Let me know if you have any questions.
Thanks.
Riz
You don' want to use a Pivot Table ?
- Battle without fear gives no glory - Just try
Sub Test() LR = Cells(Rows.Count, 2).End(xlUp).Row Sheets("Sheet2").Range("A1:A" & LR).Value = Sheets("Sheet1").Range("B1:B" & LR).Value Sheets("Sheet2").Range("$A$1:$A$" & LR).RemoveDuplicates Columns:=1, Header:=xlNo End Sub
My General Rules if you want my help. Not aimed at any person in particular:
1. Please Make Requests not demands, none of us get paid here.
2. Check back on your post regularly. I will not return to a post after 4 days.
If it is not important to you then it definitely is not important to me.
Hi Riz,
Try the attached.
Try
Option Explicit Sub Treat() Dim objSortedList As Object Set objSortedList = CreateObject("System.Collections.Sortedlist") Dim WkRg As Range Dim Rg As Range Dim I As Integer With Sheets("Sheet1") Set WkRg = Range(.Cells(2, "B"), .Cells(Rows.Count, "B").End(3)) End With For Each Rg In WkRg If (objSortedList.contains(Rg.Value)) Then Else objSortedList.Add Rg.Value, "" End If Next With objSortedList For I = 0 To .Count - 1 Sheets("Sheet2").Range("A5").Offset(I, 0) = .getkey(I) Next End With End Sub
Different method
Sub test() Dim a, e a = Sheets("sheet1").Columns("b").SpecialCells(2).Value With CreateObject("System.Collections.ArrayList") For Each e In a If Not .Contains(e) Then .Add e Next .Sort: a = Application.Transpose(.ToArray) End With Sheets("sheet2").[a5].Resize(UBound(a, 1)) = a End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks