+ Reply to Thread
Results 1 to 5 of 5

Importing formulas/code from one cell to another, to affect multiple cells.

  1. #1
    Registered User
    Join Date
    03-05-2014
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2011 Mac
    Posts
    4

    Question Importing formulas/code from one cell to another, to affect multiple cells.

    Hi

    I'm a newbie in Excel (actually been using it for several years, but only for very simple stuff).
    I'm trying to put together a meal planner / nutrition calculator for my girlfriend. I want to make it smart.

    The idea is to select an item i one cell, which in return will affect the following cells with the nutritional values. So far so good.
    I would then like, if a given amount is entered, it calculates the values.

    A food item is typed in Cell A. The following cells will Index Match a table (on a different sheet), importing calculation formulas based on the food items nutritional value (Cells C - G). If an amount is typed in Cell B (i.e. 100 grams) the following cells will then calculate the correct nutritional values.
    Via an old post on this forum, i learned to make an INDEX MATCH function, so that when i type "Gulerod" or something like that, the following cells import information from the Table tab... When the table contains fixed values, this works just fine. However - i tried to make the table (the cells) with calculation formulas (i.e. =SUM(4*B3))... this means the values in the tables are 0 untill a value is typed in B3 (in this example).
    ... however when i do the Index Match in my main tab, only the "0"'s are imported, and no matter what value i enter in B3 in the main tab, the following cells remains with the fixed value 0.

    ... so my question is - is it even possible to have the Index Match function import the calculation formula from the table and have it work in the main tab as well? Or is there any other way to make this work in Excel? Basically - to have the main sheet find the relevant data to use for calculation on a different tab/sheet, and then do the actually calculations on the main tab/sheet.

    If attached my attempt, if this helps clarify.Planner_example.xlsx (Food items are written in Danish - sorry, the rest should have been translated, and hopefully still give the idea i'm looking for)

    Thank you all for any help.
    Last edited by AirSteward; 03-07-2014 at 12:44 PM. Reason: Quote tags didn't work at first.

  2. #2
    Registered User
    Join Date
    03-05-2014
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2011 Mac
    Posts
    4

    Lightbulb Re: Importing formulas/code from one cell to another, to affect multiple cells.

    Hi again...
    ... i might actually have found a solution to my problem myself. It's not very elegant - but it does seem to work. If anybody had an more elegant solution, i'd be more than happy to hear about it!

    In my main tab/sheet i used these formulas (references varying to the respective cells):

    =SUM(((IF($A6=""; ""; INDEX(Tabel!C:C; MATCH($A6; Tabel!$A:$A; 0))))/100)*B6)
    Edit: Code language has been changed into English from Danish.

    Now at least, it imports the data from the Tabel sheet to the main sheet, and let's me use those data to calculate in the main sheet.
    Untill i fill in the numbers to offset the calculations, the cells does display errormessages... any way to "hide" those, so the cell just looks empty?

    As i said - it's not elegant coding - so if anyone has a better solution - more elegant, easier, better... I'd be more than happy to hear about it!

    I'll leave this thread open for just a little longer to see if any suggestions come in.
    Last edited by AirSteward; 03-05-2014 at 08:59 AM. Reason: Changed the code language to English from Danish

  3. #3
    Registered User
    Join Date
    02-17-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Importing formulas/code from one cell to another, to affect multiple cells.

    Hi,

    I don't think I understand what you're trying to do, but what I'd want to do is be able to enter the amount of food eaten in a meal (or day) in the B column of the 'Calculus' tab, and specify the calorie per unit weight in the 'Tabel' tab.

    If this is what you want to do as well, this may help. Use this formula in cell C6 and drag to end of table in the 'Calculus' tab.

    Formula: copy to clipboard
    Please Login or Register  to view this content.



    To remove the error messages, just use-

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    03-05-2014
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2011 Mac
    Posts
    4

    Re: Importing formulas/code from one cell to another, to affect multiple cells.

    I'll give it a try... i does look slightly more elegant than my solution :-)

    Thank you for taking the time!

  5. #5
    Registered User
    Join Date
    03-05-2014
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2011 Mac
    Posts
    4

    Thumbs up Re: Importing formulas/code from one cell to another, to affect multiple cells.

    I'll give it a try... i does look slightly more elegant than my solution :-)

    Thank you for taking the time!

  6. #6
    Registered User
    Join Date
    03-05-2014
    Location
    Copenhagen, Denmark
    MS-Off Ver
    Excel 2011 Mac
    Posts
    4

    Re: Importing formulas/code from one cell to another, to affect multiple cells.

    Your code works too...

    ... and i finally figured out how to use the IFERROR code you gave... so simple when you get it. I'm a slow learner, but a learner none the less.

    Thanks for all the help. I consider this a solved problem. Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How can I use multiple macros that affect different cells in one sheet
    By Silenz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-24-2013, 06:15 AM
  2. Code to have dropdown data affect adjacent cell
    By stickingissues in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-15-2012, 12:09 PM
  3. Replies: 7
    Last Post: 03-22-2012, 01:09 AM
  4. How to get drop down list value to affect multiple cells
    By cwhitmore in forum Excel General
    Replies: 5
    Last Post: 02-03-2012, 06:48 PM
  5. Importing information from one cell into multiple cells
    By Goodz in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-26-2008, 06:53 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1