How to remove all emojis from excel

1

I have an excel sheet that I want to export to MySQL using the "MySQL for Excel" feature. However I'm having trouble getting that to work because some of the cells have emojis such as in it. And so I can't convert those cells to be of datatype text for MySQL. I tried using CLEAN() but it doesn't get rid of them.

Is there a way to filter out these emojis?

If there are other alternatives or work around that would allow me to export the excel data to MySQL I'm open to that as well. Thank you.

Alice

Posted 2017-10-15T01:48:48.407

Reputation: 33

1You probably need to set encoding for your MySQL database to UTF-8 rather than cleaning the data. – wvxvw – 2017-10-15T11:28:30.987

That would be utf8mb4 in MySQL (not just utf8), because historical reasons... – user1686 – 2017-10-15T15:40:20.383

Answers

1

If your emojis are Shapes, then within Excel, using VBA, run this simple macro:

Sub dural()
    Dim sh As Shape

    If ActiveSheet.Shapes.Count <> 0 Then
        For Each sh In ActiveSheet.Shapes
            sh.Delete
        Next
    End If
End Sub

EDIT#1:

If the emojis are Text, then select a cell and:

Sub kleanIt()
    Dim r As Range, v As Variant, L As Long
    Dim CH As String, i As Long, N As Long

    Set r = ActiveCell
    v = r.Value
    L = Len(v)

    For i = L To 1 Step -1
        CH = Mid(v, i, 1)
        N = AscW(CH)
        If N < 1 Or N > 256 Then
            v = Replace(v, CH, "")
        End If
    Next i

    r.Value = v
End Sub

Gary's Student

Posted 2017-10-15T01:48:48.407

Reputation: 15 540

But they're technically text, not Shapes... – user1686 – 2017-10-15T15:41:38.007

@grawity If the are text, then all you need is the unicode value (either decimal or hex) for each emoji to remove it by Find/Replace – Gary's Student – 2017-10-15T15:44:30.437

@grawity See my EDIT#1 – Gary's Student – 2017-10-15T16:24:08.560

@Gary'sStudent It was text. The code works, thank you! – Alice – 2017-11-02T10:40:47.730

@Alice You are quite welcome! – Gary's Student – 2017-11-02T10:43:26.817