Excel: can offset use a corresponding code as a value in another column?












1















First off, I've tried to do my research, but I'm so inexperienced I don't know what I don't know, and I don't know how to ask the right question. I'd imagine my whole issue is just not understanding the functionality of excel.



I'll start by explaining my story and goals - I'm open to trying a more efficient method!



TL;DR - I need to create some sort of column search function that offsets a value



My Story:

So, I am about to launch an online personal training business. One of my services is nutrition coaching, and I'll be creating weekly meal plans for clients. To create these meal plans I want to be able to create a 'preset meal' button that I can easily press to add a given preset to the meal plan. I've been operating inefficiently, where I manually enter the quantity of each ingredient each time. I have tables for the different food groups (meat, grains, dairy, fruit, veg, other), they will be set up like the following. In this example, one of the required ingredients is 2 slices of ham (see Column F);



This is the previously set up macro, it was selecting a given Cell, not finding the ingredient and inputing a value from an offset
screen of the code



Example of table now
Example of table now



Column A - Ingredient - e.g;



Meat Table;'pork_ham_slice'



Column B - Energy (kj) - e.g;



Meat Table;'460'



Column C:E - Carbs(g)|Protein(g)|Fat(g) - e.g;



Meat Table;'7'|'15'|'2.5'



Column F - Quantity - e.g; -



Meat Table;'2'



Column G - Energy (kj)x Column F - e.g;



Meat Table;'920'



Column H:J - [Carbs(g)|Protein(g)|Fat(g)]x Column F - e.g;



Meat Table;'14'|'30'|'5'



My Goal: I want to be able to create a button/macro that will search Column A for the given ingredient, before inputing a value into Column F. I had started creating a few buttons where they input values into a specific Cell in Column A, however, I will continually be adding more ingredients, and I want the Column A to be sorted alphabetically, which instantly throws off this set cell method as I add a new ingredient.



At the end of the day, I thought some combination of VLOOKUP and OFFSET could be used, but I just can't figure this one out - Youtube isn't enough, and here we are.



If any of this was unclear, I'm more than happy to provide further details!



Guy










share|improve this question

























  • Please show us your work sor far and your exact table structure - screenshots would be very helpful.

    – Michal Rosa
    Nov 20 '18 at 4:47











  • Please always include the code in your question and format it as code block. An image of your code is not helpful.

    – Pᴇʜ
    Nov 20 '18 at 7:27








  • 1





    You will find this very helpful in terms of speeding up your code by avoiding .Select.

    – QHarr
    Nov 20 '18 at 7:51
















1















First off, I've tried to do my research, but I'm so inexperienced I don't know what I don't know, and I don't know how to ask the right question. I'd imagine my whole issue is just not understanding the functionality of excel.



I'll start by explaining my story and goals - I'm open to trying a more efficient method!



TL;DR - I need to create some sort of column search function that offsets a value



My Story:

So, I am about to launch an online personal training business. One of my services is nutrition coaching, and I'll be creating weekly meal plans for clients. To create these meal plans I want to be able to create a 'preset meal' button that I can easily press to add a given preset to the meal plan. I've been operating inefficiently, where I manually enter the quantity of each ingredient each time. I have tables for the different food groups (meat, grains, dairy, fruit, veg, other), they will be set up like the following. In this example, one of the required ingredients is 2 slices of ham (see Column F);



This is the previously set up macro, it was selecting a given Cell, not finding the ingredient and inputing a value from an offset
screen of the code



Example of table now
Example of table now



Column A - Ingredient - e.g;



Meat Table;'pork_ham_slice'



Column B - Energy (kj) - e.g;



Meat Table;'460'



Column C:E - Carbs(g)|Protein(g)|Fat(g) - e.g;



Meat Table;'7'|'15'|'2.5'



Column F - Quantity - e.g; -



Meat Table;'2'



Column G - Energy (kj)x Column F - e.g;



Meat Table;'920'



Column H:J - [Carbs(g)|Protein(g)|Fat(g)]x Column F - e.g;



Meat Table;'14'|'30'|'5'



My Goal: I want to be able to create a button/macro that will search Column A for the given ingredient, before inputing a value into Column F. I had started creating a few buttons where they input values into a specific Cell in Column A, however, I will continually be adding more ingredients, and I want the Column A to be sorted alphabetically, which instantly throws off this set cell method as I add a new ingredient.



At the end of the day, I thought some combination of VLOOKUP and OFFSET could be used, but I just can't figure this one out - Youtube isn't enough, and here we are.



If any of this was unclear, I'm more than happy to provide further details!



Guy










share|improve this question

























  • Please show us your work sor far and your exact table structure - screenshots would be very helpful.

    – Michal Rosa
    Nov 20 '18 at 4:47











  • Please always include the code in your question and format it as code block. An image of your code is not helpful.

    – Pᴇʜ
    Nov 20 '18 at 7:27








  • 1





    You will find this very helpful in terms of speeding up your code by avoiding .Select.

    – QHarr
    Nov 20 '18 at 7:51














1












1








1








First off, I've tried to do my research, but I'm so inexperienced I don't know what I don't know, and I don't know how to ask the right question. I'd imagine my whole issue is just not understanding the functionality of excel.



I'll start by explaining my story and goals - I'm open to trying a more efficient method!



TL;DR - I need to create some sort of column search function that offsets a value



My Story:

So, I am about to launch an online personal training business. One of my services is nutrition coaching, and I'll be creating weekly meal plans for clients. To create these meal plans I want to be able to create a 'preset meal' button that I can easily press to add a given preset to the meal plan. I've been operating inefficiently, where I manually enter the quantity of each ingredient each time. I have tables for the different food groups (meat, grains, dairy, fruit, veg, other), they will be set up like the following. In this example, one of the required ingredients is 2 slices of ham (see Column F);



This is the previously set up macro, it was selecting a given Cell, not finding the ingredient and inputing a value from an offset
screen of the code



Example of table now
Example of table now



Column A - Ingredient - e.g;



Meat Table;'pork_ham_slice'



Column B - Energy (kj) - e.g;



Meat Table;'460'



Column C:E - Carbs(g)|Protein(g)|Fat(g) - e.g;



Meat Table;'7'|'15'|'2.5'



Column F - Quantity - e.g; -



Meat Table;'2'



Column G - Energy (kj)x Column F - e.g;



Meat Table;'920'



Column H:J - [Carbs(g)|Protein(g)|Fat(g)]x Column F - e.g;



Meat Table;'14'|'30'|'5'



My Goal: I want to be able to create a button/macro that will search Column A for the given ingredient, before inputing a value into Column F. I had started creating a few buttons where they input values into a specific Cell in Column A, however, I will continually be adding more ingredients, and I want the Column A to be sorted alphabetically, which instantly throws off this set cell method as I add a new ingredient.



At the end of the day, I thought some combination of VLOOKUP and OFFSET could be used, but I just can't figure this one out - Youtube isn't enough, and here we are.



If any of this was unclear, I'm more than happy to provide further details!



Guy










share|improve this question
















First off, I've tried to do my research, but I'm so inexperienced I don't know what I don't know, and I don't know how to ask the right question. I'd imagine my whole issue is just not understanding the functionality of excel.



I'll start by explaining my story and goals - I'm open to trying a more efficient method!



TL;DR - I need to create some sort of column search function that offsets a value



My Story:

So, I am about to launch an online personal training business. One of my services is nutrition coaching, and I'll be creating weekly meal plans for clients. To create these meal plans I want to be able to create a 'preset meal' button that I can easily press to add a given preset to the meal plan. I've been operating inefficiently, where I manually enter the quantity of each ingredient each time. I have tables for the different food groups (meat, grains, dairy, fruit, veg, other), they will be set up like the following. In this example, one of the required ingredients is 2 slices of ham (see Column F);



This is the previously set up macro, it was selecting a given Cell, not finding the ingredient and inputing a value from an offset
screen of the code



Example of table now
Example of table now



Column A - Ingredient - e.g;



Meat Table;'pork_ham_slice'



Column B - Energy (kj) - e.g;



Meat Table;'460'



Column C:E - Carbs(g)|Protein(g)|Fat(g) - e.g;



Meat Table;'7'|'15'|'2.5'



Column F - Quantity - e.g; -



Meat Table;'2'



Column G - Energy (kj)x Column F - e.g;



Meat Table;'920'



Column H:J - [Carbs(g)|Protein(g)|Fat(g)]x Column F - e.g;



Meat Table;'14'|'30'|'5'



My Goal: I want to be able to create a button/macro that will search Column A for the given ingredient, before inputing a value into Column F. I had started creating a few buttons where they input values into a specific Cell in Column A, however, I will continually be adding more ingredients, and I want the Column A to be sorted alphabetically, which instantly throws off this set cell method as I add a new ingredient.



At the end of the day, I thought some combination of VLOOKUP and OFFSET could be used, but I just can't figure this one out - Youtube isn't enough, and here we are.



If any of this was unclear, I'm more than happy to provide further details!



Guy







excel vba excel-formula






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 20 '18 at 7:30









Pᴇʜ

22.8k62950




22.8k62950










asked Nov 20 '18 at 4:34









Guy LeggettGuy Leggett

62




62













  • Please show us your work sor far and your exact table structure - screenshots would be very helpful.

    – Michal Rosa
    Nov 20 '18 at 4:47











  • Please always include the code in your question and format it as code block. An image of your code is not helpful.

    – Pᴇʜ
    Nov 20 '18 at 7:27








  • 1





    You will find this very helpful in terms of speeding up your code by avoiding .Select.

    – QHarr
    Nov 20 '18 at 7:51



















  • Please show us your work sor far and your exact table structure - screenshots would be very helpful.

    – Michal Rosa
    Nov 20 '18 at 4:47











  • Please always include the code in your question and format it as code block. An image of your code is not helpful.

    – Pᴇʜ
    Nov 20 '18 at 7:27








  • 1





    You will find this very helpful in terms of speeding up your code by avoiding .Select.

    – QHarr
    Nov 20 '18 at 7:51

















Please show us your work sor far and your exact table structure - screenshots would be very helpful.

– Michal Rosa
Nov 20 '18 at 4:47





Please show us your work sor far and your exact table structure - screenshots would be very helpful.

– Michal Rosa
Nov 20 '18 at 4:47













Please always include the code in your question and format it as code block. An image of your code is not helpful.

– Pᴇʜ
Nov 20 '18 at 7:27







Please always include the code in your question and format it as code block. An image of your code is not helpful.

– Pᴇʜ
Nov 20 '18 at 7:27






1




1





You will find this very helpful in terms of speeding up your code by avoiding .Select.

– QHarr
Nov 20 '18 at 7:51





You will find this very helpful in terms of speeding up your code by avoiding .Select.

– QHarr
Nov 20 '18 at 7:51












1 Answer
1






active

oldest

votes


















0














To give you an example how to find a specific value in a table:



Dim FoundIngredient As Range
Set FoundIngredient = Worksheets("MeatTable").Range("A:A").Find(What:="Pork_Ham_Slice", LookAt:=xlWhole)

If FoundIngredient Is Nothing Then
MsgBox "ingredient not found"
Exit Sub
Else
FoundIngredient.Offset(ColumnOffset:=5).Value = 2
End If





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%2f53386303%2fexcel-can-offset-use-a-corresponding-code-as-a-value-in-another-column%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    To give you an example how to find a specific value in a table:



    Dim FoundIngredient As Range
    Set FoundIngredient = Worksheets("MeatTable").Range("A:A").Find(What:="Pork_Ham_Slice", LookAt:=xlWhole)

    If FoundIngredient Is Nothing Then
    MsgBox "ingredient not found"
    Exit Sub
    Else
    FoundIngredient.Offset(ColumnOffset:=5).Value = 2
    End If





    share|improve this answer




























      0














      To give you an example how to find a specific value in a table:



      Dim FoundIngredient As Range
      Set FoundIngredient = Worksheets("MeatTable").Range("A:A").Find(What:="Pork_Ham_Slice", LookAt:=xlWhole)

      If FoundIngredient Is Nothing Then
      MsgBox "ingredient not found"
      Exit Sub
      Else
      FoundIngredient.Offset(ColumnOffset:=5).Value = 2
      End If





      share|improve this answer


























        0












        0








        0







        To give you an example how to find a specific value in a table:



        Dim FoundIngredient As Range
        Set FoundIngredient = Worksheets("MeatTable").Range("A:A").Find(What:="Pork_Ham_Slice", LookAt:=xlWhole)

        If FoundIngredient Is Nothing Then
        MsgBox "ingredient not found"
        Exit Sub
        Else
        FoundIngredient.Offset(ColumnOffset:=5).Value = 2
        End If





        share|improve this answer













        To give you an example how to find a specific value in a table:



        Dim FoundIngredient As Range
        Set FoundIngredient = Worksheets("MeatTable").Range("A:A").Find(What:="Pork_Ham_Slice", LookAt:=xlWhole)

        If FoundIngredient Is Nothing Then
        MsgBox "ingredient not found"
        Exit Sub
        Else
        FoundIngredient.Offset(ColumnOffset:=5).Value = 2
        End If






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 '18 at 7:38









        PᴇʜPᴇʜ

        22.8k62950




        22.8k62950
































            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%2f53386303%2fexcel-can-offset-use-a-corresponding-code-as-a-value-in-another-column%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

            鏡平學校

            ꓛꓣだゔៀៅຸ໢ທຮ໕໒ ,ໂ'໥໓າ໼ឨឲ៵៭ៈゎゔit''䖳𥁄卿' ☨₤₨こゎもょの;ꜹꟚꞖꞵꟅꞛေၦေɯ,ɨɡ𛃵𛁹ޝ޳ޠ޾,ޤޒޯ޾𫝒𫠁သ𛅤チョ'サノބޘދ𛁐ᶿᶇᶀᶋᶠ㨑㽹⻮ꧬ꧹؍۩وَؠ㇕㇃㇪ ㇦㇋㇋ṜẰᵡᴠ 軌ᵕ搜۳ٰޗޮ޷ސޯ𫖾𫅀ल, ꙭ꙰ꚅꙁꚊꞻꝔ꟠Ꝭㄤﺟޱސꧨꧼ꧴ꧯꧽ꧲ꧯ'⽹⽭⾁⿞⼳⽋២៩ញណើꩯꩤ꩸ꩮᶻᶺᶧᶂ𫳲𫪭𬸄𫵰𬖩𬫣𬊉ၲ𛅬㕦䬺𫝌𫝼,,𫟖𫞽ហៅ஫㆔ాఆఅꙒꚞꙍ,Ꙟ꙱エ ,ポテ,フࢰࢯ𫟠𫞶 𫝤𫟠ﺕﹱﻜﻣ𪵕𪭸𪻆𪾩𫔷ġ,ŧآꞪ꟥,ꞔꝻ♚☹⛵𛀌ꬷꭞȄƁƪƬșƦǙǗdžƝǯǧⱦⱰꓕꓢႋ神 ဴ၀க௭எ௫ឫោ ' េㇷㇴㇼ神ㇸㇲㇽㇴㇼㇻㇸ'ㇸㇿㇸㇹㇰㆣꓚꓤ₡₧ ㄨㄟ㄂ㄖㄎ໗ツڒذ₶।ऩछएोञयूटक़कयँृी,冬'𛅢𛅥ㇱㇵㇶ𥄥𦒽𠣧𠊓𧢖𥞘𩔋цѰㄠſtʯʭɿʆʗʍʩɷɛ,əʏダヵㄐㄘR{gỚṖḺờṠṫảḙḭᴮᵏᴘᵀᵷᵕᴜᴏᵾq﮲ﲿﴽﭙ軌ﰬﶚﶧ﫲Ҝжюїкӈㇴffצּ﬘﭅﬈軌'ffistfflſtffतभफɳɰʊɲʎ𛁱𛁖𛁮𛀉 𛂯𛀞నఋŀŲ 𫟲𫠖𫞺ຆຆ ໹້໕໗ๆทԊꧢꧠ꧰ꓱ⿝⼑ŎḬẃẖỐẅ ,ờỰỈỗﮊDžȩꭏꭎꬻ꭮ꬿꭖꭥꭅ㇭神 ⾈ꓵꓑ⺄㄄ㄪㄙㄅㄇstA۵䞽ॶ𫞑𫝄㇉㇇゜軌𩜛𩳠Jﻺ‚Üမ႕ႌႊၐၸဓၞၞၡ៸wyvtᶎᶪᶹစဎ꣡꣰꣢꣤ٗ؋لㇳㇾㇻㇱ㆐㆔,,㆟Ⱶヤマފ޼ޝަݿݞݠݷݐ',ݘ,ݪݙݵ𬝉𬜁𫝨𫞘くせぉて¼óû×ó£…𛅑הㄙくԗԀ5606神45,神796'𪤻𫞧ꓐ㄁ㄘɥɺꓵꓲ3''7034׉ⱦⱠˆ“𫝋ȍ,ꩲ軌꩷ꩶꩧꩫఞ۔فڱێظペサ神ナᴦᵑ47 9238їﻂ䐊䔉㠸﬎ffiﬣ,לּᴷᴦᵛᵽ,ᴨᵤ ᵸᵥᴗᵈꚏꚉꚟ⻆rtǟƴ𬎎

            Why https connections are so slow when debugging (stepping over) in Java?