Avatar of Flora Edwards
Flora Edwards
Flag for Sweden asked on

how to convert this sub to a UDF

I had this question after viewing Formula to extract unique string from sheet2 column C.


how to convert this code into UDF

Sub macro()
Set ws2 = Sheets("Sheet2")
lr = ws2.Cells(Rows.Count, 3).End(xlUp).Row

Set Rng = ws2.Range(Range("C2"), ws2.Range("C" & Rows.Count).End(xlUp))
Set dict = CreateObject("Scripting.Dictionary")

For Each c In Rng
    dict(c.Value) = ""
Next
arrKeys = dict.Keys
res = Join(arrKeys, ",")
Sheets("Sheet1").Range("A1") = res
End Sub

Open in new window

VBA

Avatar of undefined
Last Comment
Flora Edwards

8/22/2022 - Mon
Martin Liss

What do you want to do with each row?
ASKER CERTIFIED SOLUTION
Norie

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Flora Edwards

ASKER
Perfect!  Thanks a million Norie
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck