Function to return range of unique values

thequickness

New Member
Joined
Jul 17, 2019
Messages
10
I have a Column(H) that is 2000+ rows large, and will increase as I add more data. In this Columns there is only 4 unique values. Ex: H2:H600 = AAA, H601:H1200 = BBB, H1201:H1800 = CCC, and so on....

How do I get the range returned to a variable of all of the AAA, and BBB, and CCC.

Code:
dim searchRange as range
searchRange = rngCheck


function rngCheck() as Range

dim lastRow = activesheet.range("H10000").End(xlUp).row

for i = 2 to lastRow
....get my AAA range here...
next i
end function
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
What are your unique values?
 
Upvote 0
Technically they are time stamps 4/19/2019 07:50:22 is the fist that goes from h2:h2685, but I won't know the time stamps, or the range end. The next is 4/19/2019 07:49:23, 4/19/2019 07:47:32 and 4/3/2019 10:10:12
 
Upvote 0
How about
Code:
Sub thequickness()
   Dim UsdRws As Long, i As Long
   Dim ary(1 To 4) As Range
   
   
   With ActiveSheet
      UsdRws = Range("H" & Rows.Count).End(xlUp).Row
      For i = 1 To 4
         If i = 1 Then
            Set ary(i) = Range("H2")
         Else
            Set ary(i) = ary(i - 1).Offset(ary(i - 1).Count)(1)
         End If
         .Range("H1:H" & UsdRws).AutoFilter 1, CStr(ary(i).Value)
         Set ary(i) = .AutoFilter.Range.Offset(1).Resize(UsdRws - 1).SpecialCells(xlVisible)
      Next i
      .AutoFilterMode = False
   End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top