How do I remove certain text from a cell in Excel?












0















I have a cell in Excel that contains the following:



@dickfundy @ThatKevinSmith @aliciamalone @MovieMantz @dickfundy nope just Stranger Things Season 2 or Ready Player https:xxxxxxxxxxx



I want to remove the usernames (everything starting with a "@") and I also want to remove the web-link (the "https:xxxxxxxxxxx"), and I want to end up with this in the cell:



nope just Stranger Things Season 2 or Ready Player



I have 60,000 other cells that contain similar text. How do I do this?










share|improve this question























  • It looks like this question is related to another discussion on Stack Overflow available here: stackoverflow.com/questions/13957975/…

    – Harvey A. Ramer
    Nov 14 '18 at 1:50











  • what version of excel?

    – Ron Rosenfeld
    Nov 14 '18 at 2:00











  • @RonRosenfeld Microsoft Excel for Mac Version 16.16.4 (181110)

    – rsmalley74
    Nov 14 '18 at 2:19











  • Do you have the TEXTJOIN function?

    – Ron Rosenfeld
    Nov 14 '18 at 2:19













  • @RonRosenfeld yes but it doesn't apply here as all text is already in the same cell

    – rsmalley74
    Nov 14 '18 at 2:35
















0















I have a cell in Excel that contains the following:



@dickfundy @ThatKevinSmith @aliciamalone @MovieMantz @dickfundy nope just Stranger Things Season 2 or Ready Player https:xxxxxxxxxxx



I want to remove the usernames (everything starting with a "@") and I also want to remove the web-link (the "https:xxxxxxxxxxx"), and I want to end up with this in the cell:



nope just Stranger Things Season 2 or Ready Player



I have 60,000 other cells that contain similar text. How do I do this?










share|improve this question























  • It looks like this question is related to another discussion on Stack Overflow available here: stackoverflow.com/questions/13957975/…

    – Harvey A. Ramer
    Nov 14 '18 at 1:50











  • what version of excel?

    – Ron Rosenfeld
    Nov 14 '18 at 2:00











  • @RonRosenfeld Microsoft Excel for Mac Version 16.16.4 (181110)

    – rsmalley74
    Nov 14 '18 at 2:19











  • Do you have the TEXTJOIN function?

    – Ron Rosenfeld
    Nov 14 '18 at 2:19













  • @RonRosenfeld yes but it doesn't apply here as all text is already in the same cell

    – rsmalley74
    Nov 14 '18 at 2:35














0












0








0








I have a cell in Excel that contains the following:



@dickfundy @ThatKevinSmith @aliciamalone @MovieMantz @dickfundy nope just Stranger Things Season 2 or Ready Player https:xxxxxxxxxxx



I want to remove the usernames (everything starting with a "@") and I also want to remove the web-link (the "https:xxxxxxxxxxx"), and I want to end up with this in the cell:



nope just Stranger Things Season 2 or Ready Player



I have 60,000 other cells that contain similar text. How do I do this?










share|improve this question














I have a cell in Excel that contains the following:



@dickfundy @ThatKevinSmith @aliciamalone @MovieMantz @dickfundy nope just Stranger Things Season 2 or Ready Player https:xxxxxxxxxxx



I want to remove the usernames (everything starting with a "@") and I also want to remove the web-link (the "https:xxxxxxxxxxx"), and I want to end up with this in the cell:



nope just Stranger Things Season 2 or Ready Player



I have 60,000 other cells that contain similar text. How do I do this?







excel






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 14 '18 at 0:25









rsmalley74rsmalley74

184




184













  • It looks like this question is related to another discussion on Stack Overflow available here: stackoverflow.com/questions/13957975/…

    – Harvey A. Ramer
    Nov 14 '18 at 1:50











  • what version of excel?

    – Ron Rosenfeld
    Nov 14 '18 at 2:00











  • @RonRosenfeld Microsoft Excel for Mac Version 16.16.4 (181110)

    – rsmalley74
    Nov 14 '18 at 2:19











  • Do you have the TEXTJOIN function?

    – Ron Rosenfeld
    Nov 14 '18 at 2:19













  • @RonRosenfeld yes but it doesn't apply here as all text is already in the same cell

    – rsmalley74
    Nov 14 '18 at 2:35



















  • It looks like this question is related to another discussion on Stack Overflow available here: stackoverflow.com/questions/13957975/…

    – Harvey A. Ramer
    Nov 14 '18 at 1:50











  • what version of excel?

    – Ron Rosenfeld
    Nov 14 '18 at 2:00











  • @RonRosenfeld Microsoft Excel for Mac Version 16.16.4 (181110)

    – rsmalley74
    Nov 14 '18 at 2:19











  • Do you have the TEXTJOIN function?

    – Ron Rosenfeld
    Nov 14 '18 at 2:19













  • @RonRosenfeld yes but it doesn't apply here as all text is already in the same cell

    – rsmalley74
    Nov 14 '18 at 2:35

















It looks like this question is related to another discussion on Stack Overflow available here: stackoverflow.com/questions/13957975/…

– Harvey A. Ramer
Nov 14 '18 at 1:50





It looks like this question is related to another discussion on Stack Overflow available here: stackoverflow.com/questions/13957975/…

– Harvey A. Ramer
Nov 14 '18 at 1:50













what version of excel?

– Ron Rosenfeld
Nov 14 '18 at 2:00





what version of excel?

– Ron Rosenfeld
Nov 14 '18 at 2:00













@RonRosenfeld Microsoft Excel for Mac Version 16.16.4 (181110)

– rsmalley74
Nov 14 '18 at 2:19





@RonRosenfeld Microsoft Excel for Mac Version 16.16.4 (181110)

– rsmalley74
Nov 14 '18 at 2:19













Do you have the TEXTJOIN function?

– Ron Rosenfeld
Nov 14 '18 at 2:19







Do you have the TEXTJOIN function?

– Ron Rosenfeld
Nov 14 '18 at 2:19















@RonRosenfeld yes but it doesn't apply here as all text is already in the same cell

– rsmalley74
Nov 14 '18 at 2:35





@RonRosenfeld yes but it doesn't apply here as all text is already in the same cell

– rsmalley74
Nov 14 '18 at 2:35












3 Answers
3






active

oldest

votes


















2














I believe your version of Excel has the TEXTJOIN function. That being the case you can use this array-formula



=TEXTJOIN(" ",TRUE,IF((LEFT(TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999)))="@")+(LEFT(TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999)),4)="http"),"",TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999))))


where seq_999 is a named formula that



refers to:  =IF(ROW(INDEX(Sheet1!$1:$65535,1,1):INDEX(Sheet1!$1:$65535,255,1))=1,1,(ROW(INDEX(Sheet1!$1:$65535,1,1):INDEX(Sheet1!$1:$65535,255,1))-1)*999)


To enter/confirm an array formula, hold down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula seen in the formula bar.






share|improve this answer
























  • I see now Ron, disregard my previous comment

    – rsmalley74
    Nov 14 '18 at 2:42











  • @rsmalley74 If this is a one-off requirement, the function is OK. If you will be doing this repeatedly on large data sets, a VBA macro will probably run much faster.

    – Ron Rosenfeld
    Nov 14 '18 at 2:45



















1














If you deleted up to the last user name (with Replace *@ with nothing) then you might apply:



=LEFT(MID(A1,FIND(" ",A1),LEN(A1)),FIND("http",MID(A1,FIND(" ",A1)+1,LEN(A1))))


SO53291434 example






share|improve this answer


























  • Thank you. It seems to work however it omits the first word that is leftover. So in the above example the word "nope" is omitted. Also, for other cells where only one word is leftover after applying this formula, the cell is then left blank.

    – rsmalley74
    Nov 14 '18 at 1:15



















1














As a UDF:



Function FixIt(s As String) As String
s = CleanUp(s, "@")
s = CleanUp(s, "http")
FixIt = Trim(s)
End Function

'remove all text segments beginning with LookFor, up to the next space
' or until the end of the input string s
Function CleanUp(s As String, LookFor As String) As String
Dim pos As Long, pos2 As Long, rv As String
rv = s
pos = InStr(1, rv, LookFor)
Do While pos > 0
pos2 = InStr(pos + 1, rv, " ")
If pos2 = 0 Then pos2 = Len(rv)
rv = Left(rv, pos - 1) & Right(rv, Len(rv) - pos2)
pos = InStr(1, rv, LookFor)
Loop
CleanUp = rv
End Function


If you want something robust:



How to use Regular Expressions (Regex) in Microsoft Excel both in-cell and loops






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291434%2fhow-do-i-remove-certain-text-from-a-cell-in-excel%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    I believe your version of Excel has the TEXTJOIN function. That being the case you can use this array-formula



    =TEXTJOIN(" ",TRUE,IF((LEFT(TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999)))="@")+(LEFT(TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999)),4)="http"),"",TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999))))


    where seq_999 is a named formula that



    refers to:  =IF(ROW(INDEX(Sheet1!$1:$65535,1,1):INDEX(Sheet1!$1:$65535,255,1))=1,1,(ROW(INDEX(Sheet1!$1:$65535,1,1):INDEX(Sheet1!$1:$65535,255,1))-1)*999)


    To enter/confirm an array formula, hold down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula seen in the formula bar.






    share|improve this answer
























    • I see now Ron, disregard my previous comment

      – rsmalley74
      Nov 14 '18 at 2:42











    • @rsmalley74 If this is a one-off requirement, the function is OK. If you will be doing this repeatedly on large data sets, a VBA macro will probably run much faster.

      – Ron Rosenfeld
      Nov 14 '18 at 2:45
















    2














    I believe your version of Excel has the TEXTJOIN function. That being the case you can use this array-formula



    =TEXTJOIN(" ",TRUE,IF((LEFT(TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999)))="@")+(LEFT(TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999)),4)="http"),"",TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999))))


    where seq_999 is a named formula that



    refers to:  =IF(ROW(INDEX(Sheet1!$1:$65535,1,1):INDEX(Sheet1!$1:$65535,255,1))=1,1,(ROW(INDEX(Sheet1!$1:$65535,1,1):INDEX(Sheet1!$1:$65535,255,1))-1)*999)


    To enter/confirm an array formula, hold down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula seen in the formula bar.






    share|improve this answer
























    • I see now Ron, disregard my previous comment

      – rsmalley74
      Nov 14 '18 at 2:42











    • @rsmalley74 If this is a one-off requirement, the function is OK. If you will be doing this repeatedly on large data sets, a VBA macro will probably run much faster.

      – Ron Rosenfeld
      Nov 14 '18 at 2:45














    2












    2








    2







    I believe your version of Excel has the TEXTJOIN function. That being the case you can use this array-formula



    =TEXTJOIN(" ",TRUE,IF((LEFT(TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999)))="@")+(LEFT(TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999)),4)="http"),"",TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999))))


    where seq_999 is a named formula that



    refers to:  =IF(ROW(INDEX(Sheet1!$1:$65535,1,1):INDEX(Sheet1!$1:$65535,255,1))=1,1,(ROW(INDEX(Sheet1!$1:$65535,1,1):INDEX(Sheet1!$1:$65535,255,1))-1)*999)


    To enter/confirm an array formula, hold down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula seen in the formula bar.






    share|improve this answer













    I believe your version of Excel has the TEXTJOIN function. That being the case you can use this array-formula



    =TEXTJOIN(" ",TRUE,IF((LEFT(TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999)))="@")+(LEFT(TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999)),4)="http"),"",TRIM(MID(SUBSTITUTE(TRIM(A1)," ",REPT(" ",999)),seq_999,999))))


    where seq_999 is a named formula that



    refers to:  =IF(ROW(INDEX(Sheet1!$1:$65535,1,1):INDEX(Sheet1!$1:$65535,255,1))=1,1,(ROW(INDEX(Sheet1!$1:$65535,1,1):INDEX(Sheet1!$1:$65535,255,1))-1)*999)


    To enter/confirm an array formula, hold down ctrl + shift while hitting enter. If you do this correctly, Excel will place braces {...} around the formula seen in the formula bar.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 14 '18 at 2:29









    Ron RosenfeldRon Rosenfeld

    23.2k41636




    23.2k41636













    • I see now Ron, disregard my previous comment

      – rsmalley74
      Nov 14 '18 at 2:42











    • @rsmalley74 If this is a one-off requirement, the function is OK. If you will be doing this repeatedly on large data sets, a VBA macro will probably run much faster.

      – Ron Rosenfeld
      Nov 14 '18 at 2:45



















    • I see now Ron, disregard my previous comment

      – rsmalley74
      Nov 14 '18 at 2:42











    • @rsmalley74 If this is a one-off requirement, the function is OK. If you will be doing this repeatedly on large data sets, a VBA macro will probably run much faster.

      – Ron Rosenfeld
      Nov 14 '18 at 2:45

















    I see now Ron, disregard my previous comment

    – rsmalley74
    Nov 14 '18 at 2:42





    I see now Ron, disregard my previous comment

    – rsmalley74
    Nov 14 '18 at 2:42













    @rsmalley74 If this is a one-off requirement, the function is OK. If you will be doing this repeatedly on large data sets, a VBA macro will probably run much faster.

    – Ron Rosenfeld
    Nov 14 '18 at 2:45





    @rsmalley74 If this is a one-off requirement, the function is OK. If you will be doing this repeatedly on large data sets, a VBA macro will probably run much faster.

    – Ron Rosenfeld
    Nov 14 '18 at 2:45













    1














    If you deleted up to the last user name (with Replace *@ with nothing) then you might apply:



    =LEFT(MID(A1,FIND(" ",A1),LEN(A1)),FIND("http",MID(A1,FIND(" ",A1)+1,LEN(A1))))


    SO53291434 example






    share|improve this answer


























    • Thank you. It seems to work however it omits the first word that is leftover. So in the above example the word "nope" is omitted. Also, for other cells where only one word is leftover after applying this formula, the cell is then left blank.

      – rsmalley74
      Nov 14 '18 at 1:15
















    1














    If you deleted up to the last user name (with Replace *@ with nothing) then you might apply:



    =LEFT(MID(A1,FIND(" ",A1),LEN(A1)),FIND("http",MID(A1,FIND(" ",A1)+1,LEN(A1))))


    SO53291434 example






    share|improve this answer


























    • Thank you. It seems to work however it omits the first word that is leftover. So in the above example the word "nope" is omitted. Also, for other cells where only one word is leftover after applying this formula, the cell is then left blank.

      – rsmalley74
      Nov 14 '18 at 1:15














    1












    1








    1







    If you deleted up to the last user name (with Replace *@ with nothing) then you might apply:



    =LEFT(MID(A1,FIND(" ",A1),LEN(A1)),FIND("http",MID(A1,FIND(" ",A1)+1,LEN(A1))))


    SO53291434 example






    share|improve this answer















    If you deleted up to the last user name (with Replace *@ with nothing) then you might apply:



    =LEFT(MID(A1,FIND(" ",A1),LEN(A1)),FIND("http",MID(A1,FIND(" ",A1)+1,LEN(A1))))


    SO53291434 example







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 14 '18 at 1:26

























    answered Nov 14 '18 at 0:34









    pnutspnuts

    48.4k76297




    48.4k76297













    • Thank you. It seems to work however it omits the first word that is leftover. So in the above example the word "nope" is omitted. Also, for other cells where only one word is leftover after applying this formula, the cell is then left blank.

      – rsmalley74
      Nov 14 '18 at 1:15



















    • Thank you. It seems to work however it omits the first word that is leftover. So in the above example the word "nope" is omitted. Also, for other cells where only one word is leftover after applying this formula, the cell is then left blank.

      – rsmalley74
      Nov 14 '18 at 1:15

















    Thank you. It seems to work however it omits the first word that is leftover. So in the above example the word "nope" is omitted. Also, for other cells where only one word is leftover after applying this formula, the cell is then left blank.

    – rsmalley74
    Nov 14 '18 at 1:15





    Thank you. It seems to work however it omits the first word that is leftover. So in the above example the word "nope" is omitted. Also, for other cells where only one word is leftover after applying this formula, the cell is then left blank.

    – rsmalley74
    Nov 14 '18 at 1:15











    1














    As a UDF:



    Function FixIt(s As String) As String
    s = CleanUp(s, "@")
    s = CleanUp(s, "http")
    FixIt = Trim(s)
    End Function

    'remove all text segments beginning with LookFor, up to the next space
    ' or until the end of the input string s
    Function CleanUp(s As String, LookFor As String) As String
    Dim pos As Long, pos2 As Long, rv As String
    rv = s
    pos = InStr(1, rv, LookFor)
    Do While pos > 0
    pos2 = InStr(pos + 1, rv, " ")
    If pos2 = 0 Then pos2 = Len(rv)
    rv = Left(rv, pos - 1) & Right(rv, Len(rv) - pos2)
    pos = InStr(1, rv, LookFor)
    Loop
    CleanUp = rv
    End Function


    If you want something robust:



    How to use Regular Expressions (Regex) in Microsoft Excel both in-cell and loops






    share|improve this answer




























      1














      As a UDF:



      Function FixIt(s As String) As String
      s = CleanUp(s, "@")
      s = CleanUp(s, "http")
      FixIt = Trim(s)
      End Function

      'remove all text segments beginning with LookFor, up to the next space
      ' or until the end of the input string s
      Function CleanUp(s As String, LookFor As String) As String
      Dim pos As Long, pos2 As Long, rv As String
      rv = s
      pos = InStr(1, rv, LookFor)
      Do While pos > 0
      pos2 = InStr(pos + 1, rv, " ")
      If pos2 = 0 Then pos2 = Len(rv)
      rv = Left(rv, pos - 1) & Right(rv, Len(rv) - pos2)
      pos = InStr(1, rv, LookFor)
      Loop
      CleanUp = rv
      End Function


      If you want something robust:



      How to use Regular Expressions (Regex) in Microsoft Excel both in-cell and loops






      share|improve this answer


























        1












        1








        1







        As a UDF:



        Function FixIt(s As String) As String
        s = CleanUp(s, "@")
        s = CleanUp(s, "http")
        FixIt = Trim(s)
        End Function

        'remove all text segments beginning with LookFor, up to the next space
        ' or until the end of the input string s
        Function CleanUp(s As String, LookFor As String) As String
        Dim pos As Long, pos2 As Long, rv As String
        rv = s
        pos = InStr(1, rv, LookFor)
        Do While pos > 0
        pos2 = InStr(pos + 1, rv, " ")
        If pos2 = 0 Then pos2 = Len(rv)
        rv = Left(rv, pos - 1) & Right(rv, Len(rv) - pos2)
        pos = InStr(1, rv, LookFor)
        Loop
        CleanUp = rv
        End Function


        If you want something robust:



        How to use Regular Expressions (Regex) in Microsoft Excel both in-cell and loops






        share|improve this answer













        As a UDF:



        Function FixIt(s As String) As String
        s = CleanUp(s, "@")
        s = CleanUp(s, "http")
        FixIt = Trim(s)
        End Function

        'remove all text segments beginning with LookFor, up to the next space
        ' or until the end of the input string s
        Function CleanUp(s As String, LookFor As String) As String
        Dim pos As Long, pos2 As Long, rv As String
        rv = s
        pos = InStr(1, rv, LookFor)
        Do While pos > 0
        pos2 = InStr(pos + 1, rv, " ")
        If pos2 = 0 Then pos2 = Len(rv)
        rv = Left(rv, pos - 1) & Right(rv, Len(rv) - pos2)
        pos = InStr(1, rv, LookFor)
        Loop
        CleanUp = rv
        End Function


        If you want something robust:



        How to use Regular Expressions (Regex) in Microsoft Excel both in-cell and loops







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 14 '18 at 1:53









        Tim WilliamsTim Williams

        86.3k96885




        86.3k96885






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53291434%2fhow-do-i-remove-certain-text-from-a-cell-in-excel%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Bressuire

            Vorschmack

            Quarantine