Add numbers from string values, excel












0














I have a table which has particular string values. SP-1, SP-2, SP-3,.. SP-8
and also V-4 and V-8. I want to add numbers present in the string. The string will be same (either SP- or V-). The numbers following the string will be different. The sum should be separate for each string type.



I have seen many solutions but not able to adapt them.



The table may contain empty cells. Hence I am unable to use Value function.



I want to check the entire table for all SP- strings and V- strings and have the sum of each type. I want to achieve this using formula and not macros. Can any of you help me with the formula










share|improve this question
























  • the table that I am referring is 31*12 size (basically calendar).Having an additional column is last option. I can of course use sumif when this additional column is added for each of existing column. I used below formula. But value is resulting in #Value error because of empty cells from VALUE function.{=SUM(IF(ISNUMBER(FIND(AJ10,$E$19:E30)),VALUE(RIGHT(E19:E30,FIND(AJ10,E19:E30)-1)),0)). }
    – Vin
    Nov 20 at 17:28


















0














I have a table which has particular string values. SP-1, SP-2, SP-3,.. SP-8
and also V-4 and V-8. I want to add numbers present in the string. The string will be same (either SP- or V-). The numbers following the string will be different. The sum should be separate for each string type.



I have seen many solutions but not able to adapt them.



The table may contain empty cells. Hence I am unable to use Value function.



I want to check the entire table for all SP- strings and V- strings and have the sum of each type. I want to achieve this using formula and not macros. Can any of you help me with the formula










share|improve this question
























  • the table that I am referring is 31*12 size (basically calendar).Having an additional column is last option. I can of course use sumif when this additional column is added for each of existing column. I used below formula. But value is resulting in #Value error because of empty cells from VALUE function.{=SUM(IF(ISNUMBER(FIND(AJ10,$E$19:E30)),VALUE(RIGHT(E19:E30,FIND(AJ10,E19:E30)-1)),0)). }
    – Vin
    Nov 20 at 17:28
















0












0








0







I have a table which has particular string values. SP-1, SP-2, SP-3,.. SP-8
and also V-4 and V-8. I want to add numbers present in the string. The string will be same (either SP- or V-). The numbers following the string will be different. The sum should be separate for each string type.



I have seen many solutions but not able to adapt them.



The table may contain empty cells. Hence I am unable to use Value function.



I want to check the entire table for all SP- strings and V- strings and have the sum of each type. I want to achieve this using formula and not macros. Can any of you help me with the formula










share|improve this question















I have a table which has particular string values. SP-1, SP-2, SP-3,.. SP-8
and also V-4 and V-8. I want to add numbers present in the string. The string will be same (either SP- or V-). The numbers following the string will be different. The sum should be separate for each string type.



I have seen many solutions but not able to adapt them.



The table may contain empty cells. Hence I am unable to use Value function.



I want to check the entire table for all SP- strings and V- strings and have the sum of each type. I want to achieve this using formula and not macros. Can any of you help me with the formula







excel string excel-formula






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 at 2:35









Rubén

9,99043265




9,99043265










asked Nov 20 at 17:11









Vin

53




53












  • the table that I am referring is 31*12 size (basically calendar).Having an additional column is last option. I can of course use sumif when this additional column is added for each of existing column. I used below formula. But value is resulting in #Value error because of empty cells from VALUE function.{=SUM(IF(ISNUMBER(FIND(AJ10,$E$19:E30)),VALUE(RIGHT(E19:E30,FIND(AJ10,E19:E30)-1)),0)). }
    – Vin
    Nov 20 at 17:28




















  • the table that I am referring is 31*12 size (basically calendar).Having an additional column is last option. I can of course use sumif when this additional column is added for each of existing column. I used below formula. But value is resulting in #Value error because of empty cells from VALUE function.{=SUM(IF(ISNUMBER(FIND(AJ10,$E$19:E30)),VALUE(RIGHT(E19:E30,FIND(AJ10,E19:E30)-1)),0)). }
    – Vin
    Nov 20 at 17:28


















the table that I am referring is 31*12 size (basically calendar).Having an additional column is last option. I can of course use sumif when this additional column is added for each of existing column. I used below formula. But value is resulting in #Value error because of empty cells from VALUE function.{=SUM(IF(ISNUMBER(FIND(AJ10,$E$19:E30)),VALUE(RIGHT(E19:E30,FIND(AJ10,E19:E30)-1)),0)). }
– Vin
Nov 20 at 17:28






the table that I am referring is 31*12 size (basically calendar).Having an additional column is last option. I can of course use sumif when this additional column is added for each of existing column. I used below formula. But value is resulting in #Value error because of empty cells from VALUE function.{=SUM(IF(ISNUMBER(FIND(AJ10,$E$19:E30)),VALUE(RIGHT(E19:E30,FIND(AJ10,E19:E30)-1)),0)). }
– Vin
Nov 20 at 17:28














2 Answers
2






active

oldest

votes


















2














Use this array formula:



=SUM(IFERROR(--SUBSTITUTE($A$1:$A$6,C1&"-",""),0))


Being an array formula it needs be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.



enter image description here






share|improve this answer





















  • Thanks Scott. This helped in a quick go.
    – Vin
    Nov 20 at 17:46



















0














Try the following User Defined Function:



Public Function SpecialAdder(rng As Range, p As String) As Variant
Dim L As Long, r As Range
If p = "" Then
SpecialAdder = Application.WorksheetFunction.Sum(rng)
Exit Function
End If

SpecialAdder = 0
L = Len(p)
For Each r In rng
If Left(r.Value, L) = p Then
SpecialAdder = SpecialAdder + Mid(r.Value, L + 1)
End If
Next r
End Function


It would be used in the worksheet like:



=specialadder(A1:A100,"SP-")


enter image description here






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%2f53398113%2fadd-numbers-from-string-values-excel%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    Use this array formula:



    =SUM(IFERROR(--SUBSTITUTE($A$1:$A$6,C1&"-",""),0))


    Being an array formula it needs be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.



    enter image description here






    share|improve this answer





















    • Thanks Scott. This helped in a quick go.
      – Vin
      Nov 20 at 17:46
















    2














    Use this array formula:



    =SUM(IFERROR(--SUBSTITUTE($A$1:$A$6,C1&"-",""),0))


    Being an array formula it needs be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.



    enter image description here






    share|improve this answer





















    • Thanks Scott. This helped in a quick go.
      – Vin
      Nov 20 at 17:46














    2












    2








    2






    Use this array formula:



    =SUM(IFERROR(--SUBSTITUTE($A$1:$A$6,C1&"-",""),0))


    Being an array formula it needs be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.



    enter image description here






    share|improve this answer












    Use this array formula:



    =SUM(IFERROR(--SUBSTITUTE($A$1:$A$6,C1&"-",""),0))


    Being an array formula it needs be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode.



    enter image description here







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Nov 20 at 17:21









    Scott Craner

    88.2k82449




    88.2k82449












    • Thanks Scott. This helped in a quick go.
      – Vin
      Nov 20 at 17:46


















    • Thanks Scott. This helped in a quick go.
      – Vin
      Nov 20 at 17:46
















    Thanks Scott. This helped in a quick go.
    – Vin
    Nov 20 at 17:46




    Thanks Scott. This helped in a quick go.
    – Vin
    Nov 20 at 17:46













    0














    Try the following User Defined Function:



    Public Function SpecialAdder(rng As Range, p As String) As Variant
    Dim L As Long, r As Range
    If p = "" Then
    SpecialAdder = Application.WorksheetFunction.Sum(rng)
    Exit Function
    End If

    SpecialAdder = 0
    L = Len(p)
    For Each r In rng
    If Left(r.Value, L) = p Then
    SpecialAdder = SpecialAdder + Mid(r.Value, L + 1)
    End If
    Next r
    End Function


    It would be used in the worksheet like:



    =specialadder(A1:A100,"SP-")


    enter image description here






    share|improve this answer


























      0














      Try the following User Defined Function:



      Public Function SpecialAdder(rng As Range, p As String) As Variant
      Dim L As Long, r As Range
      If p = "" Then
      SpecialAdder = Application.WorksheetFunction.Sum(rng)
      Exit Function
      End If

      SpecialAdder = 0
      L = Len(p)
      For Each r In rng
      If Left(r.Value, L) = p Then
      SpecialAdder = SpecialAdder + Mid(r.Value, L + 1)
      End If
      Next r
      End Function


      It would be used in the worksheet like:



      =specialadder(A1:A100,"SP-")


      enter image description here






      share|improve this answer
























        0












        0








        0






        Try the following User Defined Function:



        Public Function SpecialAdder(rng As Range, p As String) As Variant
        Dim L As Long, r As Range
        If p = "" Then
        SpecialAdder = Application.WorksheetFunction.Sum(rng)
        Exit Function
        End If

        SpecialAdder = 0
        L = Len(p)
        For Each r In rng
        If Left(r.Value, L) = p Then
        SpecialAdder = SpecialAdder + Mid(r.Value, L + 1)
        End If
        Next r
        End Function


        It would be used in the worksheet like:



        =specialadder(A1:A100,"SP-")


        enter image description here






        share|improve this answer












        Try the following User Defined Function:



        Public Function SpecialAdder(rng As Range, p As String) As Variant
        Dim L As Long, r As Range
        If p = "" Then
        SpecialAdder = Application.WorksheetFunction.Sum(rng)
        Exit Function
        End If

        SpecialAdder = 0
        L = Len(p)
        For Each r In rng
        If Left(r.Value, L) = p Then
        SpecialAdder = SpecialAdder + Mid(r.Value, L + 1)
        End If
        Next r
        End Function


        It would be used in the worksheet like:



        =specialadder(A1:A100,"SP-")


        enter image description here







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 at 17:27









        Gary's Student

        72k93561




        72k93561






























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f53398113%2fadd-numbers-from-string-values-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

            To store a contact into the json file from server.js file using a class in NodeJS

            Redirect URL with Chrome Remote Debugging Android Devices

            Dieringhausen