(excel) Change value of a cell based on another value











up vote
1
down vote

favorite












Im trying to a IF statement in excel that gives a result based on the value of another cell. So for instance if cell A10 has a value of 10780 i want the cell D10 to have a value of 90310011. I can do this with the code: =IF(A10=10780;90310011). This works



enter image description here



However, i want to be able to add more values with corresponding new numbers in the same cell. So if the first cell was 10782 i want the value to be 90310012



As you can see in the picture i tried to do this with AND and also with OR. I get the result 0 with both so its not working.



Does anyone know how i should do this?



Thanks,










share|improve this question
























  • The current two answers give you nested IFs as a solution. But VLOOKUP is your friend if you are going to have more values - easier to read and much more maintainable.
    – Jan Doggen
    Dec 7 '16 at 14:36















up vote
1
down vote

favorite












Im trying to a IF statement in excel that gives a result based on the value of another cell. So for instance if cell A10 has a value of 10780 i want the cell D10 to have a value of 90310011. I can do this with the code: =IF(A10=10780;90310011). This works



enter image description here



However, i want to be able to add more values with corresponding new numbers in the same cell. So if the first cell was 10782 i want the value to be 90310012



As you can see in the picture i tried to do this with AND and also with OR. I get the result 0 with both so its not working.



Does anyone know how i should do this?



Thanks,










share|improve this question
























  • The current two answers give you nested IFs as a solution. But VLOOKUP is your friend if you are going to have more values - easier to read and much more maintainable.
    – Jan Doggen
    Dec 7 '16 at 14:36













up vote
1
down vote

favorite









up vote
1
down vote

favorite











Im trying to a IF statement in excel that gives a result based on the value of another cell. So for instance if cell A10 has a value of 10780 i want the cell D10 to have a value of 90310011. I can do this with the code: =IF(A10=10780;90310011). This works



enter image description here



However, i want to be able to add more values with corresponding new numbers in the same cell. So if the first cell was 10782 i want the value to be 90310012



As you can see in the picture i tried to do this with AND and also with OR. I get the result 0 with both so its not working.



Does anyone know how i should do this?



Thanks,










share|improve this question















Im trying to a IF statement in excel that gives a result based on the value of another cell. So for instance if cell A10 has a value of 10780 i want the cell D10 to have a value of 90310011. I can do this with the code: =IF(A10=10780;90310011). This works



enter image description here



However, i want to be able to add more values with corresponding new numbers in the same cell. So if the first cell was 10782 i want the value to be 90310012



As you can see in the picture i tried to do this with AND and also with OR. I get the result 0 with both so its not working.



Does anyone know how i should do this?



Thanks,







microsoft-excel






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 7 '16 at 13:54









User552853

1,326924




1,326924










asked Dec 7 '16 at 13:27









Rudy

612




612












  • The current two answers give you nested IFs as a solution. But VLOOKUP is your friend if you are going to have more values - easier to read and much more maintainable.
    – Jan Doggen
    Dec 7 '16 at 14:36


















  • The current two answers give you nested IFs as a solution. But VLOOKUP is your friend if you are going to have more values - easier to read and much more maintainable.
    – Jan Doggen
    Dec 7 '16 at 14:36
















The current two answers give you nested IFs as a solution. But VLOOKUP is your friend if you are going to have more values - easier to read and much more maintainable.
– Jan Doggen
Dec 7 '16 at 14:36




The current two answers give you nested IFs as a solution. But VLOOKUP is your friend if you are going to have more values - easier to read and much more maintainable.
– Jan Doggen
Dec 7 '16 at 14:36










3 Answers
3






active

oldest

votes

















up vote
0
down vote













Nest your subsequent If statement within the false option of the first If...




=IF(A10=10780,90310011,(IF(A10=12072,90310012,(IF(A10=[etc])))))




Can get messy though.



Could you update it with a macro? or does it have to be done as a formula?






share|improve this answer




























    up vote
    0
    down vote













    The IF formula has 3 parameters, where you only used 2.



    =IF( condition ; true ; false )


    The formula at the condition side is evaluated, and its either true or false.



    When its true, the formula that is located in the true section will be executed.



    When its false, the formula in the false section will be executed.



    A formula can just be a reference to another cell or even a static value. If this is the case, this is returned.



    So: =IF ( 1=2 ; "it is true" ; B4 ) will evaluate if 1=2. Its not true, so whatever value is stored in cell B4 is now returned.



    Because you can also enter formulas in the true or false result, you can nest IF statements. For example:



    =IF( 1=2 ; "first is true" ; IF( 1=3 ; "second is true" ; "Neither are true"))


    This will result in "neither are true".



    Of course, the actual condition can refer to other cells like in your question too.






    share|improve this answer




























      up vote
      0
      down vote













      It seems like your values are related by an equation... you may want to figure that out (if that's the case)



      if not, then what you want are nested IF-statements. Other people seem to have pointed that out, so I'll write it down for you in a more didactic structure



      =IF
      (
      A10=10780
      ,90310011
      ,IF
      (
      A10=12072
      ,90310012
      ,IF
      (
      A10=[...]
      )
      )
      )


      See how they're all nested whithin one another? that makes the verification of your (inner) condition dependant on the value of the (outer) condition






      share|improve this answer








      New contributor




      StructuralEng92 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.


















        Your Answer








        StackExchange.ready(function() {
        var channelOptions = {
        tags: "".split(" "),
        id: "3"
        };
        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',
        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%2fsuperuser.com%2fquestions%2f1153955%2fexcel-change-value-of-a-cell-based-on-another-value%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








        up vote
        0
        down vote













        Nest your subsequent If statement within the false option of the first If...




        =IF(A10=10780,90310011,(IF(A10=12072,90310012,(IF(A10=[etc])))))




        Can get messy though.



        Could you update it with a macro? or does it have to be done as a formula?






        share|improve this answer

























          up vote
          0
          down vote













          Nest your subsequent If statement within the false option of the first If...




          =IF(A10=10780,90310011,(IF(A10=12072,90310012,(IF(A10=[etc])))))




          Can get messy though.



          Could you update it with a macro? or does it have to be done as a formula?






          share|improve this answer























            up vote
            0
            down vote










            up vote
            0
            down vote









            Nest your subsequent If statement within the false option of the first If...




            =IF(A10=10780,90310011,(IF(A10=12072,90310012,(IF(A10=[etc])))))




            Can get messy though.



            Could you update it with a macro? or does it have to be done as a formula?






            share|improve this answer












            Nest your subsequent If statement within the false option of the first If...




            =IF(A10=10780,90310011,(IF(A10=12072,90310012,(IF(A10=[etc])))))




            Can get messy though.



            Could you update it with a macro? or does it have to be done as a formula?







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Dec 7 '16 at 14:05









            Mark

            101




            101
























                up vote
                0
                down vote













                The IF formula has 3 parameters, where you only used 2.



                =IF( condition ; true ; false )


                The formula at the condition side is evaluated, and its either true or false.



                When its true, the formula that is located in the true section will be executed.



                When its false, the formula in the false section will be executed.



                A formula can just be a reference to another cell or even a static value. If this is the case, this is returned.



                So: =IF ( 1=2 ; "it is true" ; B4 ) will evaluate if 1=2. Its not true, so whatever value is stored in cell B4 is now returned.



                Because you can also enter formulas in the true or false result, you can nest IF statements. For example:



                =IF( 1=2 ; "first is true" ; IF( 1=3 ; "second is true" ; "Neither are true"))


                This will result in "neither are true".



                Of course, the actual condition can refer to other cells like in your question too.






                share|improve this answer

























                  up vote
                  0
                  down vote













                  The IF formula has 3 parameters, where you only used 2.



                  =IF( condition ; true ; false )


                  The formula at the condition side is evaluated, and its either true or false.



                  When its true, the formula that is located in the true section will be executed.



                  When its false, the formula in the false section will be executed.



                  A formula can just be a reference to another cell or even a static value. If this is the case, this is returned.



                  So: =IF ( 1=2 ; "it is true" ; B4 ) will evaluate if 1=2. Its not true, so whatever value is stored in cell B4 is now returned.



                  Because you can also enter formulas in the true or false result, you can nest IF statements. For example:



                  =IF( 1=2 ; "first is true" ; IF( 1=3 ; "second is true" ; "Neither are true"))


                  This will result in "neither are true".



                  Of course, the actual condition can refer to other cells like in your question too.






                  share|improve this answer























                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    The IF formula has 3 parameters, where you only used 2.



                    =IF( condition ; true ; false )


                    The formula at the condition side is evaluated, and its either true or false.



                    When its true, the formula that is located in the true section will be executed.



                    When its false, the formula in the false section will be executed.



                    A formula can just be a reference to another cell or even a static value. If this is the case, this is returned.



                    So: =IF ( 1=2 ; "it is true" ; B4 ) will evaluate if 1=2. Its not true, so whatever value is stored in cell B4 is now returned.



                    Because you can also enter formulas in the true or false result, you can nest IF statements. For example:



                    =IF( 1=2 ; "first is true" ; IF( 1=3 ; "second is true" ; "Neither are true"))


                    This will result in "neither are true".



                    Of course, the actual condition can refer to other cells like in your question too.






                    share|improve this answer












                    The IF formula has 3 parameters, where you only used 2.



                    =IF( condition ; true ; false )


                    The formula at the condition side is evaluated, and its either true or false.



                    When its true, the formula that is located in the true section will be executed.



                    When its false, the formula in the false section will be executed.



                    A formula can just be a reference to another cell or even a static value. If this is the case, this is returned.



                    So: =IF ( 1=2 ; "it is true" ; B4 ) will evaluate if 1=2. Its not true, so whatever value is stored in cell B4 is now returned.



                    Because you can also enter formulas in the true or false result, you can nest IF statements. For example:



                    =IF( 1=2 ; "first is true" ; IF( 1=3 ; "second is true" ; "Neither are true"))


                    This will result in "neither are true".



                    Of course, the actual condition can refer to other cells like in your question too.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Dec 7 '16 at 14:22









                    LPChip

                    34.8k44982




                    34.8k44982






















                        up vote
                        0
                        down vote













                        It seems like your values are related by an equation... you may want to figure that out (if that's the case)



                        if not, then what you want are nested IF-statements. Other people seem to have pointed that out, so I'll write it down for you in a more didactic structure



                        =IF
                        (
                        A10=10780
                        ,90310011
                        ,IF
                        (
                        A10=12072
                        ,90310012
                        ,IF
                        (
                        A10=[...]
                        )
                        )
                        )


                        See how they're all nested whithin one another? that makes the verification of your (inner) condition dependant on the value of the (outer) condition






                        share|improve this answer








                        New contributor




                        StructuralEng92 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                        Check out our Code of Conduct.






















                          up vote
                          0
                          down vote













                          It seems like your values are related by an equation... you may want to figure that out (if that's the case)



                          if not, then what you want are nested IF-statements. Other people seem to have pointed that out, so I'll write it down for you in a more didactic structure



                          =IF
                          (
                          A10=10780
                          ,90310011
                          ,IF
                          (
                          A10=12072
                          ,90310012
                          ,IF
                          (
                          A10=[...]
                          )
                          )
                          )


                          See how they're all nested whithin one another? that makes the verification of your (inner) condition dependant on the value of the (outer) condition






                          share|improve this answer








                          New contributor




                          StructuralEng92 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                          Check out our Code of Conduct.




















                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            It seems like your values are related by an equation... you may want to figure that out (if that's the case)



                            if not, then what you want are nested IF-statements. Other people seem to have pointed that out, so I'll write it down for you in a more didactic structure



                            =IF
                            (
                            A10=10780
                            ,90310011
                            ,IF
                            (
                            A10=12072
                            ,90310012
                            ,IF
                            (
                            A10=[...]
                            )
                            )
                            )


                            See how they're all nested whithin one another? that makes the verification of your (inner) condition dependant on the value of the (outer) condition






                            share|improve this answer








                            New contributor




                            StructuralEng92 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            It seems like your values are related by an equation... you may want to figure that out (if that's the case)



                            if not, then what you want are nested IF-statements. Other people seem to have pointed that out, so I'll write it down for you in a more didactic structure



                            =IF
                            (
                            A10=10780
                            ,90310011
                            ,IF
                            (
                            A10=12072
                            ,90310012
                            ,IF
                            (
                            A10=[...]
                            )
                            )
                            )


                            See how they're all nested whithin one another? that makes the verification of your (inner) condition dependant on the value of the (outer) condition







                            share|improve this answer








                            New contributor




                            StructuralEng92 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            share|improve this answer



                            share|improve this answer






                            New contributor




                            StructuralEng92 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.









                            answered 2 days ago









                            StructuralEng92

                            1




                            1




                            New contributor




                            StructuralEng92 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.





                            New contributor





                            StructuralEng92 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






                            StructuralEng92 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                            Check out our Code of Conduct.






























                                 

                                draft saved


                                draft discarded



















































                                 


                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function () {
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1153955%2fexcel-change-value-of-a-cell-based-on-another-value%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

                                If I really need a card on my start hand, how many mulligans make sense? [duplicate]

                                Alcedinidae

                                Can an atomic nucleus contain both particles and antiparticles? [duplicate]