Excel Macro Reciprocal Conversion between two columns (lbs/kg)












-1















This is my first question here.
I am very new to excel macro/vba.
Can someone please guide me on how to create a macro which does the following:
when someone enters value into either column B (in kgs)/ or column C (in lbs), the other column gets automatically updated to reflect the appropriate value. For example, if someone entered the kgs value in column B then column c would show the lbs value and if someone entered the lbs value in column c then column b would would show the appropriate lbs value.



Thanks for your help.










share|improve this question

























  • I think this would be considered a circular reference so formulas may not work, but you can use VBA and Worksheet_Change

    – Kubie
    Nov 14 '18 at 18:09













  • You could write a macro triggered by a change in either cell that will insert the value in the other cell. this could get you started.

    – cybernetic.nomad
    Nov 14 '18 at 18:12
















-1















This is my first question here.
I am very new to excel macro/vba.
Can someone please guide me on how to create a macro which does the following:
when someone enters value into either column B (in kgs)/ or column C (in lbs), the other column gets automatically updated to reflect the appropriate value. For example, if someone entered the kgs value in column B then column c would show the lbs value and if someone entered the lbs value in column c then column b would would show the appropriate lbs value.



Thanks for your help.










share|improve this question

























  • I think this would be considered a circular reference so formulas may not work, but you can use VBA and Worksheet_Change

    – Kubie
    Nov 14 '18 at 18:09













  • You could write a macro triggered by a change in either cell that will insert the value in the other cell. this could get you started.

    – cybernetic.nomad
    Nov 14 '18 at 18:12














-1












-1








-1


0






This is my first question here.
I am very new to excel macro/vba.
Can someone please guide me on how to create a macro which does the following:
when someone enters value into either column B (in kgs)/ or column C (in lbs), the other column gets automatically updated to reflect the appropriate value. For example, if someone entered the kgs value in column B then column c would show the lbs value and if someone entered the lbs value in column c then column b would would show the appropriate lbs value.



Thanks for your help.










share|improve this question
















This is my first question here.
I am very new to excel macro/vba.
Can someone please guide me on how to create a macro which does the following:
when someone enters value into either column B (in kgs)/ or column C (in lbs), the other column gets automatically updated to reflect the appropriate value. For example, if someone entered the kgs value in column B then column c would show the lbs value and if someone entered the lbs value in column c then column b would would show the appropriate lbs value.



Thanks for your help.







excel vba excel-vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 7:47









Pᴇʜ

23k62950




23k62950










asked Nov 14 '18 at 18:08









xissa11xissa11

11




11













  • I think this would be considered a circular reference so formulas may not work, but you can use VBA and Worksheet_Change

    – Kubie
    Nov 14 '18 at 18:09













  • You could write a macro triggered by a change in either cell that will insert the value in the other cell. this could get you started.

    – cybernetic.nomad
    Nov 14 '18 at 18:12



















  • I think this would be considered a circular reference so formulas may not work, but you can use VBA and Worksheet_Change

    – Kubie
    Nov 14 '18 at 18:09













  • You could write a macro triggered by a change in either cell that will insert the value in the other cell. this could get you started.

    – cybernetic.nomad
    Nov 14 '18 at 18:12

















I think this would be considered a circular reference so formulas may not work, but you can use VBA and Worksheet_Change

– Kubie
Nov 14 '18 at 18:09







I think this would be considered a circular reference so formulas may not work, but you can use VBA and Worksheet_Change

– Kubie
Nov 14 '18 at 18:09















You could write a macro triggered by a change in either cell that will insert the value in the other cell. this could get you started.

– cybernetic.nomad
Nov 14 '18 at 18:12





You could write a macro triggered by a change in either cell that will insert the value in the other cell. this could get you started.

– cybernetic.nomad
Nov 14 '18 at 18:12












2 Answers
2






active

oldest

votes


















1














If you go to the VBE Editor and double-click on the sheet you want to monitor, you can place this Sub there:



Sub Worksheet_Change(ByVal Target As Range)

Dim cel As Variant

If Target.Cells.Count > 1 Then Exit Sub
If IsNumeric(Target.Value) = False Then Exit Sub

If Target.Column = 2 Then

' data entered in column B, so change C
Target.Offset(0,1).Value = Target.Value * 2.2

ElseIf Target.Column = 3 Then

' data entered in column C, so change B
Target.Offset(0,-1).Value = Target.Value / 2.2

End If

End Sub





share|improve this answer


























  • I get a compile error while trying to run. it highlights: Else If Target.Column = 3 Then

    – xissa11
    Nov 14 '18 at 18:37













  • @xissa11 oops remove the space between Else and If

    – Kubie
    Nov 14 '18 at 18:39








  • 1





    thanks a bunch. works like a charm!

    – xissa11
    Nov 14 '18 at 18:46











  • @xissa11 just please keep in mind this can break if you copy & paste a bunch of values

    – Kubie
    Nov 14 '18 at 18:46











  • @xissa11 I added a line of code for it to exit if it detects a copy-paste

    – Kubie
    Nov 14 '18 at 18:56



















0














Possible with a formula where that example would need to be adapted with appropriate conversion factors.






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%2f53306362%2fexcel-macro-reciprocal-conversion-between-two-columns-lbs-kg%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









    1














    If you go to the VBE Editor and double-click on the sheet you want to monitor, you can place this Sub there:



    Sub Worksheet_Change(ByVal Target As Range)

    Dim cel As Variant

    If Target.Cells.Count > 1 Then Exit Sub
    If IsNumeric(Target.Value) = False Then Exit Sub

    If Target.Column = 2 Then

    ' data entered in column B, so change C
    Target.Offset(0,1).Value = Target.Value * 2.2

    ElseIf Target.Column = 3 Then

    ' data entered in column C, so change B
    Target.Offset(0,-1).Value = Target.Value / 2.2

    End If

    End Sub





    share|improve this answer


























    • I get a compile error while trying to run. it highlights: Else If Target.Column = 3 Then

      – xissa11
      Nov 14 '18 at 18:37













    • @xissa11 oops remove the space between Else and If

      – Kubie
      Nov 14 '18 at 18:39








    • 1





      thanks a bunch. works like a charm!

      – xissa11
      Nov 14 '18 at 18:46











    • @xissa11 just please keep in mind this can break if you copy & paste a bunch of values

      – Kubie
      Nov 14 '18 at 18:46











    • @xissa11 I added a line of code for it to exit if it detects a copy-paste

      – Kubie
      Nov 14 '18 at 18:56
















    1














    If you go to the VBE Editor and double-click on the sheet you want to monitor, you can place this Sub there:



    Sub Worksheet_Change(ByVal Target As Range)

    Dim cel As Variant

    If Target.Cells.Count > 1 Then Exit Sub
    If IsNumeric(Target.Value) = False Then Exit Sub

    If Target.Column = 2 Then

    ' data entered in column B, so change C
    Target.Offset(0,1).Value = Target.Value * 2.2

    ElseIf Target.Column = 3 Then

    ' data entered in column C, so change B
    Target.Offset(0,-1).Value = Target.Value / 2.2

    End If

    End Sub





    share|improve this answer


























    • I get a compile error while trying to run. it highlights: Else If Target.Column = 3 Then

      – xissa11
      Nov 14 '18 at 18:37













    • @xissa11 oops remove the space between Else and If

      – Kubie
      Nov 14 '18 at 18:39








    • 1





      thanks a bunch. works like a charm!

      – xissa11
      Nov 14 '18 at 18:46











    • @xissa11 just please keep in mind this can break if you copy & paste a bunch of values

      – Kubie
      Nov 14 '18 at 18:46











    • @xissa11 I added a line of code for it to exit if it detects a copy-paste

      – Kubie
      Nov 14 '18 at 18:56














    1












    1








    1







    If you go to the VBE Editor and double-click on the sheet you want to monitor, you can place this Sub there:



    Sub Worksheet_Change(ByVal Target As Range)

    Dim cel As Variant

    If Target.Cells.Count > 1 Then Exit Sub
    If IsNumeric(Target.Value) = False Then Exit Sub

    If Target.Column = 2 Then

    ' data entered in column B, so change C
    Target.Offset(0,1).Value = Target.Value * 2.2

    ElseIf Target.Column = 3 Then

    ' data entered in column C, so change B
    Target.Offset(0,-1).Value = Target.Value / 2.2

    End If

    End Sub





    share|improve this answer















    If you go to the VBE Editor and double-click on the sheet you want to monitor, you can place this Sub there:



    Sub Worksheet_Change(ByVal Target As Range)

    Dim cel As Variant

    If Target.Cells.Count > 1 Then Exit Sub
    If IsNumeric(Target.Value) = False Then Exit Sub

    If Target.Column = 2 Then

    ' data entered in column B, so change C
    Target.Offset(0,1).Value = Target.Value * 2.2

    ElseIf Target.Column = 3 Then

    ' data entered in column C, so change B
    Target.Offset(0,-1).Value = Target.Value / 2.2

    End If

    End Sub






    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Nov 14 '18 at 18:56

























    answered Nov 14 '18 at 18:23









    KubieKubie

    1,3421518




    1,3421518













    • I get a compile error while trying to run. it highlights: Else If Target.Column = 3 Then

      – xissa11
      Nov 14 '18 at 18:37













    • @xissa11 oops remove the space between Else and If

      – Kubie
      Nov 14 '18 at 18:39








    • 1





      thanks a bunch. works like a charm!

      – xissa11
      Nov 14 '18 at 18:46











    • @xissa11 just please keep in mind this can break if you copy & paste a bunch of values

      – Kubie
      Nov 14 '18 at 18:46











    • @xissa11 I added a line of code for it to exit if it detects a copy-paste

      – Kubie
      Nov 14 '18 at 18:56



















    • I get a compile error while trying to run. it highlights: Else If Target.Column = 3 Then

      – xissa11
      Nov 14 '18 at 18:37













    • @xissa11 oops remove the space between Else and If

      – Kubie
      Nov 14 '18 at 18:39








    • 1





      thanks a bunch. works like a charm!

      – xissa11
      Nov 14 '18 at 18:46











    • @xissa11 just please keep in mind this can break if you copy & paste a bunch of values

      – Kubie
      Nov 14 '18 at 18:46











    • @xissa11 I added a line of code for it to exit if it detects a copy-paste

      – Kubie
      Nov 14 '18 at 18:56

















    I get a compile error while trying to run. it highlights: Else If Target.Column = 3 Then

    – xissa11
    Nov 14 '18 at 18:37







    I get a compile error while trying to run. it highlights: Else If Target.Column = 3 Then

    – xissa11
    Nov 14 '18 at 18:37















    @xissa11 oops remove the space between Else and If

    – Kubie
    Nov 14 '18 at 18:39







    @xissa11 oops remove the space between Else and If

    – Kubie
    Nov 14 '18 at 18:39






    1




    1





    thanks a bunch. works like a charm!

    – xissa11
    Nov 14 '18 at 18:46





    thanks a bunch. works like a charm!

    – xissa11
    Nov 14 '18 at 18:46













    @xissa11 just please keep in mind this can break if you copy & paste a bunch of values

    – Kubie
    Nov 14 '18 at 18:46





    @xissa11 just please keep in mind this can break if you copy & paste a bunch of values

    – Kubie
    Nov 14 '18 at 18:46













    @xissa11 I added a line of code for it to exit if it detects a copy-paste

    – Kubie
    Nov 14 '18 at 18:56





    @xissa11 I added a line of code for it to exit if it detects a copy-paste

    – Kubie
    Nov 14 '18 at 18:56













    0














    Possible with a formula where that example would need to be adapted with appropriate conversion factors.






    share|improve this answer




























      0














      Possible with a formula where that example would need to be adapted with appropriate conversion factors.






      share|improve this answer


























        0












        0








        0







        Possible with a formula where that example would need to be adapted with appropriate conversion factors.






        share|improve this answer













        Possible with a formula where that example would need to be adapted with appropriate conversion factors.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 24 '18 at 13:07









        pnutspnuts

        48.5k76299




        48.5k76299






























            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%2f53306362%2fexcel-macro-reciprocal-conversion-between-two-columns-lbs-kg%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

            Florida Star v. B. J. F.

            Danny Elfman

            Lugert, Oklahoma