How to get emojis displayed in excel instead of the hex codes?

AD04

New Member
Joined
Jan 26, 2021
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Hello. I've scraped tweets that contain emojis in an Excel sheet, however, the emojis/emoticons are displayed as hex codes. Could you please help me with getting them displayed as emojis?
Thanks.

g3l.xlsx
AB
1tweetscleaned_tweets_with_emojis
2Lets go @KingJames !!!! We got this @Lakers !!!!!!!! 11:11 #LakeShow
3Cmon @Lakers we got this!! <U+0001F49C><U+0001F49B> #LakeShow #LAKERSNATION
4Me giving my energy to the @Lakers so we can win in the 4th quarter #LakeShow #LakersNation https://t.co/GbMHFaFwEE
5Okay okay...I guess @Lakers, we can’t make it too easy...Lakers in 5, we can give them this game <U+0001F605> #LakeShow
6Helluva game from @JimmyButler. Let’s see if we get a repeat in game 3. The @Lakers can’t play this poorly again, right?! #LakeShow
7Not surprised of this result. We sorta knew @lakers werent going to come in as expected. It always takes a lost to wake up. On to the next. #lakersin5 #LakeShow #LakersNation
8Great job @Lakers <U+0001F608><U+0001F4AA><U+0001F3FE><U+0001F4AA><U+0001F3FE> we still on top #NBAnaESPN #LakeShow
Sheet2
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
I can think of a way, assuming some things ... like, all emojis are together, and no other ">" character will be in the tweet, and if you are happy with 7 or so extra columns, and that the emojis will be in black-and-white, like this:
sandbox101.xlsb
ABCDEFGHI
1tweetscleaned_tweets_with_emojisemoj1emoj2emoj3emoj4emoj5emoj6all emoji
2Lets go @KingJames !!!! We got this @Lakers !!!!!!!! 11:11 #LakeShowLets go @KingJames !!!! We got this @Lakers !!!!!!!! 11:11 #LakeShow       
3Cmon @Lakers we got this!! <U+0001F49C><U+0001F49B> #LakeShow #LAKERSNATIONCmon @Lakers we got this!! ?? #LakeShow #LAKERSNATION??    ??
4Me giving my energy to the @Lakers so we can win in the 4th quarter #LakeShow #LakersNation https://t.co/GbMHFaFwEEMe giving my energy to the @Lakers so we can win in the 4th quarter #LakeShow #LakersNation https://t.co/GbMHFaFwEE       
5Okay okay...I guess @Lakers, we can’t make it too easy...Lakers in 5, we can give them this game <U+0001F605> #LakeShowOkay okay...I guess @Lakers, we can't make it too easy...Lakers in 5, we can give them this game ? #LakeShow?     ?
6Helluva game from @JimmyButler. Let’s see if we get a repeat in game 3. The @Lakers can’t play this poorly again, right?! #LakeShowHelluva game from @JimmyButler. Let's see if we get a repeat in game 3. The @Lakers can't play this poorly again, right?! #LakeShow       
7Not surprised of this result. We sorta knew @lakers werent going to come in as expected. It always takes a lost to wake up. On to the next. #lakersin5 #LakeShow #LakersNationNot surprised of this result. We sorta knew @lakers werent going to come in as expected. It always takes a lost to wake up. On to the next. #lakersin5 #LakeShow #LakersNation       
8Great job @Lakers <U+0001F608><U+0001F4AA><U+0001F3FE><U+0001F4AA><U+0001F3FE> we still on top #NBAnaESPN #LakeShowGreat job @Lakers ????? we still on top #NBAnaESPN #LakeShow????? ?????
Sheet10
Cell Formulas
RangeFormula
B2:B8B2=IF(ISERROR(FIND("<U+",A2)),SUBSTITUTE(A2,"’","'"),SUBSTITUTE(REPLACE(A2,FIND("<U+",A2),FIND("^",SUBSTITUTE(A2,">","^",LEN(A2)-LEN(SUBSTITUTE(A2,">",""))))-FIND("<U+",A2)+1,I2),"’","'"))
C2:H8C2=IFERROR(UNICHAR(HEX2DEC(MID($A2,FIND("^",SUBSTITUTE($A2,"<U+","^",VALUE(RIGHT(C$1,1))))+6,5))),"")
I2:I8I2=C2&D2&E2&F2&G2&H2
 
Upvote 0
Solution
Hi, Glenn. Your response is much appreciated. I'm unable to completely wrap my head around how you came up with the B2 formula. Since I've to extract emojis for thousands of tweets with multiple permutations of text, characters, and emojis, could you please explain the formula?
Thanks, again.
 
Upvote 0
Hi AD04, the B2 formula simply replaces whatever is between "<U+" and the final ">" with whatever is in cell I2 (and convert "’" to apostrophe). Do you need more details?
 
Upvote 0
Also, do you need alternative formulas ... for example, do you have emojis that are not all in one lump (clump, or contiguous set, or together, or however you want to say it)?
 
Upvote 0
Just in case:

hexcode_to_emoji_by_formula.xlsx
ABCDEFGHI
1tweetscleaned_tweets_with_emojischange code for apostrophe to real onereplace 1replace 2replace 3replace 4replace 5replace 6
2Lets go @KingJames !!!! We got this @Lakers !!!!!!!! 11:11 #LakeShowLets go @KingJames !!!! We got this @Lakers !!!!!!!! 11:11 #LakeShowLets go @KingJames !!!! We got this @Lakers !!!!!!!! 11:11 #LakeShow      
3Cmon @Lakers we got this!! <U+0001F49C><U+0001F49B> #LakeShow #LAKERSNATIONCmon @Lakers we got this!! ?? #LakeShow #LAKERSNATIONCmon @Lakers we got this!! <U+0001F49C><U+0001F49B> #LakeShow #LAKERSNATIONCmon @Lakers we got this!! ?<U+0001F49B> #LakeShow #LAKERSNATIONCmon @Lakers we got this!! ?? #LakeShow #LAKERSNATION    
4Me giving my energy to the @Lakers so we can win in the 4th quarter #LakeShow #LakersNation https://t.co/GbMHFaFwEEMe giving my energy to the @Lakers so we can win in the 4th quarter #LakeShow #LakersNation https://t.co/GbMHFaFwEEMe giving my energy to the @Lakers so we can win in the 4th quarter #LakeShow #LakersNation https://t.co/GbMHFaFwEE      
5Okay okay...I guess @Lakers, we can’t make it too easy...Lakers in 5, we can give them this game <U+0001F605> #LakeShowOkay okay...I guess @Lakers, we can't make it too easy...Lakers in 5, we can give them this game ? #LakeShowOkay okay...I guess @Lakers, we can't make it too easy...Lakers in 5, we can give them this game <U+0001F605> #LakeShowOkay okay...I guess @Lakers, we can't make it too easy...Lakers in 5, we can give them this game ? #LakeShow     
6Helluva game from @JimmyButler. Let’s see if we get a repeat in game 3. The @Lakers can’t play this poorly again, right?! #LakeShowHelluva game from @JimmyButler. Let's see if we get a repeat in game 3. The @Lakers can't play this poorly again, right?! #LakeShowHelluva game from @JimmyButler. Let's see if we get a repeat in game 3. The @Lakers can't play this poorly again, right?! #LakeShow      
7Not surprised of this result. We sorta knew @lakers werent going to come in as expected. It always takes a lost to wake up. On to the next. #lakersin5 #LakeShow #LakersNationNot surprised of this result. We sorta knew @lakers werent going to come in as expected. It always takes a lost to wake up. On to the next. #lakersin5 #LakeShow #LakersNationNot surprised of this result. We sorta knew @lakers werent going to come in as expected. It always takes a lost to wake up. On to the next. #lakersin5 #LakeShow #LakersNation      
8Great job @Lakers <U+0001F608><U+0001F4AA><U+0001F3FE><U+0001F4AA><U+0001F3FE> we still on top #NBAnaESPN #LakeShowGreat job @Lakers ????? we still on top #NBAnaESPN #LakeShowGreat job @Lakers <U+0001F608><U+0001F4AA><U+0001F3FE><U+0001F4AA><U+0001F3FE> we still on top #NBAnaESPN #LakeShowGreat job @Lakers ?<U+0001F4AA><U+0001F3FE><U+0001F4AA><U+0001F3FE> we still on top #NBAnaESPN #LakeShowGreat job @Lakers ??<U+0001F3FE><U+0001F4AA><U+0001F3FE> we still on top #NBAnaESPN #LakeShowGreat job @Lakers ???<U+0001F4AA><U+0001F3FE> we still on top #NBAnaESPN #LakeShowGreat job @Lakers ????<U+0001F3FE> we still on top #NBAnaESPN #LakeShowGreat job @Lakers ????? we still on top #NBAnaESPN #LakeShow 
example mixed emojis and text
Cell Formulas
RangeFormula
B2:B8B2=INDEX(C2:I2,7-COUNTIF(C2:I2,""))
C2:C8C2=SUBSTITUTE(A2,"’","'")
D2:I8D2=IF(ISERROR(FIND("<U+",C2)),"",REPLACE(C2,FIND("<U+",C2),12,UNICHAR(HEX2DEC(MID(C2,FIND("<U+",C2)+6,5)))))
 
Upvote 0
You could use a macro as well:

VBA Code:
Sub testA()
Dim FindCell As Range, mr As Range, a As Long, b As String, c As Long

    Set mr = Range("A2:A10")
    mr.Replace what:="’", replacement:="'"
    Do
        Set FindCell = mr.Find("<U+")
        If FindCell Is Nothing Then Exit Do
        a = InStr(FindCell.Value, "<U+")
        b = Mid(FindCell.Value, a, 12)
        c = WorksheetFunction.Hex2Dec(Mid(b, 4, 8))
        mr.Replace what:=b, replacement:=WorksheetFunction.Unichar(c)
    Loop
        
End Sub

Set the range on the first line. Then run it, and it will replace the <U+ ... with the actual emoji.
 
Upvote 0
That helps, thanks. How about the last bit of the code: -FIND("<U+",A2)+1,I2.

I get the part that the hexcodes are subtracted but why is I2 mentioned?
 
Upvote 0
Also, do you need alternative formulas ... for example, do you have emojis that are not all in one lump (clump, or contiguous set, or together, or however you want to say it)?
I'd really appreciate that, @GlennUK . And yes, the emojis are all over the place, usually in the middle and the end of the tweet but not necessarily altogether.
 
Upvote 0
Hi, @Eric W . Thanks for the macro. I noticed the tweets have funky characters as follows:
- ÂÂ
- â€Å

I'd like to remove these with a blank space.
 
Upvote 0

Forum statistics

Threads
1,214,912
Messages
6,122,204
Members
449,072
Latest member
DW Draft

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