+ Reply to Thread
Results 1 to 9 of 9

How to assign values

  1. #1
    Registered User
    Join Date
    03-27-2024
    Location
    EU
    MS-Off Ver
    MS 365 A3 Student
    Posts
    4

    How to assign values

    Hello,

    I am not new to Excel but it has been quite a while, therefore I am out of shape. I want to build a calorie calculator + create dieting plans, but I need your help.

    1. I want to have a list of different products, such a rice, chicken etc. and assign those to their respective calories and
    2. with the help of that list create dieting plans.

    So when I defined that rice should only calculated in 100 grams and bread in pcs., when I type in bread in 1 column and the quantitiy in another column, it should give the total calories. Sounds pretty easy imo. But I dont get how to assign
    1. the calories and 2. the type of quanitity (Pcs or 100 grams) to the products. Is there a formula that lets me define Rice == Pieces, Rice == 180 kcal.? I defined rice with the help of variables, but when it comes to the calculation, I couldnt define the type of quantity for the products. I just need to be able to create a list that defines these variables to the products.

    Thank you for your help

  2. #2
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: How to assign values

    Welcome to the forum.

    Please attache a file and help us to help you.

  3. #3
    Registered User
    Join Date
    03-27-2024
    Location
    EU
    MS-Off Ver
    MS 365 A3 Student
    Posts
    4

    Re: How to assign values

    Thank you for your reply. I have uploaded a representative data sheet Diet_Plan.xlsx

    I dont want it to be hardcoded, I want it to function automatically when I use the plan and fill in the product names and quantity, it should give me the total calories.

    How can I implement the logic behind the quantity? The system must know that rice is calcualted with 100g increments and Bread with pcs. These information should be assigned in the list/register.
    Attached Images Attached Images

  4. #4
    Forum Expert
    Join Date
    10-19-2021
    Location
    Brazil
    MS-Off Ver
    Office 365 V2401 w/ Win10 Home 64 Bit
    Posts
    2,014

    Re: How to assign values

    Could use this.

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

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: How to assign values

    Administrative Note:

    Welcome to the forum.

    Although we value your privacy as much you do, it could be important that members have a rough idea of your location as the solutions they offer may be affected by your locale. For instance, you might in the future post questions which are related to your regional settings.

    With this in mind, please update your profile to something more precise (something such as UK, Europe, USA, UAE, etc. will suffice).

    Thank you for helping us to help you.

    Administrative Note:

    Is your forum profile showing the Excel PRODUCT that you need this to work for?

    Members will tailor the solutions they offer to the Office PRODUCT (Excel, NOT Windows) that you have. Please check that your forum profile is up-to-date in this respect. If you aren't sure, in Excel go to File | Account and report what it says below the MS logo at the top of that page. If your product is for Mac, please also state this.

    The three most recent Excel products are Excel 2019, Excel 2021 and MS365 - if you are using MS365, please give this name along with the version number in your profile (e.g. MS365 Version 2306). This is in the About Excel section further down the Account page.

    Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  6. #6
    Registered User
    Join Date
    03-27-2024
    Location
    EU
    MS-Off Ver
    MS 365 A3 Student
    Posts
    4

    Re: How to assign values

    Your help is appreciated! I will implement it in my sheet, thank you

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,869

    Re: How to assign values

    Please take note of post #5 and update your profile accordingly. Thanks.

  8. #8
    Registered User
    Join Date
    03-27-2024
    Location
    EU
    MS-Off Ver
    MS 365 A3 Student
    Posts
    4

    Re: How to assign values

    Hey,

    I am back again with a question concerning your code. I changed the quantity type from "200 g" to "200" and "1 Pcs." to "1" to simplify it, but the code stopped working after that change. It seems that there must appear a letter or number after the quantity number to make it work, but I dont get why it actually needs this. I tried to understand the code and the part where this part is defined but I couldnt grasp it. Could you explain it to me?

  9. #9
    Forum Expert azumi's Avatar
    Join Date
    12-10-2012
    Location
    YK, Indonesia
    MS-Off Ver
    Excel 2019
    Posts
    2,368

    Re: How to assign values

    Maybe:

    =IFERROR(IFERROR(TEXTBEFORE($G9," ",1),"")/IFERROR(INDEX(TEXTBEFORE($B$10:$B$12," ",1)+0,MATCH($F9,$A$10:$A$12,0)),"")*$C10,"")

    formula from@DJunqueira works by the way
    Last edited by azumi; 04-01-2024 at 12:46 AM.

+ 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. Trying to assign values from a column to specific values in a row.
    By SoRad in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 07-28-2017, 02:37 PM
  2. Assign values to categories of values based on separate column attribute.
    By jenbot83 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-06-2017, 02:17 PM
  3. Applying Formula to assign numeric values to text values in sequential order
    By jmshanahan in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-15-2016, 03:04 PM
  4. [SOLVED] Formula to assign Values from groups of Values
    By hammer2 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 12-27-2015, 10:31 AM
  5. [SOLVED] Need to assign different gradient values based upon values
    By codelphi in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-23-2014, 05:24 AM
  6. Setting threshold to assign real values to class values
    By themoss1985 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-29-2011, 11:50 PM
  7. assign SEQ# for same values
    By lisa6538 in forum Excel General
    Replies: 1
    Last Post: 03-19-2007, 11:38 PM

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