return all text strings beginning with "#" from a column

cosgrove

New Member
Joined
Mar 10, 2011
Messages
3
Hi, I have a single column with 860,000 rows (each cell is a tweet) and I need to extract all unique hashtags from that column.
(A hashtag is a text string that begins with "#" and has no spaces, but will vary in length.)
Many cells contain multiple hashtags, and the vast majority of hashtags will show up in hundreds or even thousands of cells. I need a simple list of all unique hashtags, and expect there to be between 200-500.
Any suggestions? Thanks so much.
 
Shorter, faster, same output.
Code:
Sub another()
Dim n&, e, x, d As New dictionary 'ref MS scripting runtime
n = Cells(Rows.Count, 1).End(3).Row
For Each e In Range("A1").Resize(n).Value
    x = Split(e, "#", -1)
    For j = 1 To UBound(x)
       d("#" & Split(x(j), " ")(0)) = 0
    Next j
Next e
[d1].Resize(d.Count) = Application.Transpose(d.Keys)
End Sub
 
Upvote 0

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.

Forum statistics

Threads
1,225,155
Messages
6,183,211
Members
453,151
Latest member
Lizamaison

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