Dear all,
I'm facing an issue in Naming a Range.
Sample Data:
Grades
1
1
2
2
3
3
I would like to get the above values as:
1
2
3
Name the Range of Values (1,2,3) as "Grades".
Please see the below code which will print the unique values(here, grades) in column D.
Option Explicit
Sub GetUniqueGrades()
Sheets("Grades").Select
Range("A1").Select
Dim d As Object
Dim c As Variant
Dim i, lr As Long
Set d = CreateObject("Scripting.Dictionary")
lr = Cells(Rows.Count, 1).End(xlUp).Row
c = Range("A2:A" & lr)
For i = 1 To UBound(c, 1)
d(c(i, 1)) = 1
Next i
Range("D2").Resize(d.Count) = Application.Transpose(d.keys)
End Sub
PFA for reference.
I would like these unique values to be considered as a Range of Values and also Name that Range.
Note: Code to do the needful without Printing the unique values in a separate column.
Please let me know if this would be possible
Thanks,
Vinod Krishna
Bookmarks