Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 10-11-2018, 06:30 AM
NoSparks NoSparks is offline Loop through cells and return only unique values Windows 7 64bit Loop through cells and return only unique values Office 2010 64bit
Excel Hobbyist
 
Join Date: Nov 2013
Location: British Columbia, Canada
Posts: 842
NoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of lightNoSparks is a glorious beacon of light
Default

Here's a bit of code that you should be able to adapt
Code:
Sub Uniques_From_Column()
    Dim lr As Long, i As Long
    Dim dic As Object
    Dim arr As Variant
    
With Sheets("Sheet1")
    lr = .Cells.Find(What:="*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
    arr = .Range("B2:B" & lr)
End With

Set dic = CreateObject("Scripting.Dictionary")

For i = 1 To UBound(arr, 1)
  dic(arr(i, 1)) = 1
Next i

'write uniques to a column
Range("E2").Resize(dic.Count) = Application.Transpose(dic.keys)
' or
'do something with each unique
For i = 0 To dic.Count - 1
    'do what you want with each
    'this prints to the immediate window
    Debug.Print dic.keys()(i)
Next i

End Sub

Excel VBA Dictionary – A Complete Guide

Last edited by NoSparks; 10-11-2018 at 09:42 AM. Reason: add link
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to group table by unique values in PowerPivot rlf793 Excel 0 05-17-2017 05:23 PM
Count Duplicate Values without a specific Unique Value Brittni Excel 1 02-01-2017 06:22 PM
Loop through cells and return only unique values Count unique values that match 2 or more criteria caeiro01 Excel 1 10-25-2015 02:34 AM
Loop through cells and return only unique values Combining Records of two sheets with Loop till Unique ID abhilashv Mail Merge 1 01-22-2014 04:02 AM
Loop through cells and return only unique values Display unique values and count the number of child items vthomeschoolmom Excel 2 07-25-2013 06:17 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:43 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft