+ Reply to Thread
Results 1 to 24 of 24

Bidirectional percentage- weight formula?

  1. #1
    Registered User
    Join Date
    08-07-2017
    Location
    .
    MS-Off Ver
    2016
    Posts
    11

    Bidirectional percentage- weight formula?

    Hello all,

    I start with a pic so its easier to explane.

    Capture.JPG

    How can this be made so into one table that its possible input percentages or weight in grams from the total?
    Now I'm using two different tables, other which calculates percentage from total, and other which calculates ingredient weight.

    Edit: I added the original sheet
    Attached Files Attached Files
    Last edited by naubusan; 08-07-2017 at 07:42 AM. Reason: Added excelsheet

  2. #2
    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,409

    Re: Bidirectional percentage- weight formula?

    Try this in C9 copied down:

    =B9/100*B$6

    and the other way in B9 copied down:

    =C9/B$6*100
    Last edited by AliGW; 08-07-2017 at 07:42 AM.
    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.

  3. #3
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Bidirectional percentage- weight formula?

    or using a setup like the one in the sheet...
    Attached Files Attached Files
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  4. #4
    Registered User
    Join Date
    08-07-2017
    Location
    .
    MS-Off Ver
    2016
    Posts
    11

    Re: Bidirectional percentage- weight formula?

    Quote Originally Posted by AliGW View Post
    Try this in C9 copied down:

    =B9/100*B$6

    and the other way in B9 copied down:

    =C9/B$6*100
    You guys are fast Thanks

    This is what I tried to achieve but this formula gives an error.
    Capture2.JPG

    I edited First post to include sheet which calculates weight in grams from the total.

  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,409

    Re: Bidirectional percentage- weight formula?

    You can't have both on the same table - you said you had two tables - use the first in the percentage to grams table and the second in the grams to percentgae table. Adapt the cell references for the second table if it is in a different place.

  6. #6
    Registered User
    Join Date
    08-07-2017
    Location
    .
    MS-Off Ver
    2016
    Posts
    11

    Re: Bidirectional percentage- weight formula?

    Tried to google this and found some vba scripts which were working like this. But I don't understand vb enough to create working script on my purpose.

  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,409

    Re: Bidirectional percentage- weight formula?

    Ah, OK - you want it in one table. Sorry - my misunderstanding.

  8. #8
    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,409

    Re: Bidirectional percentage- weight formula?

    Did you look at post #3?

  9. #9
    Registered User
    Join Date
    08-07-2017
    Location
    .
    MS-Off Ver
    2016
    Posts
    11

    Re: Bidirectional percentage- weight formula?

    Yes, Thanks Glenn, that's working solution although quite not what I was thinking.

  10. #10
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Bidirectional percentage- weight formula?

    Hi all- This seems to work. Paste this in B9 and copy down:
    =IF(ISFORMULA(C9),"-",C9/$B$6*100)

    ...and this in C9 and copy down:
    =IF(ISFORMULA(B9),"-",$B$6*B9/100)

    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
    Last edited by leelnich; 08-07-2017 at 08:54 AM.

  11. #11
    Registered User
    Join Date
    08-07-2017
    Location
    .
    MS-Off Ver
    2016
    Posts
    11

    Re: Bidirectional percentage- weight formula?

    Quote Originally Posted by leelnich View Post
    Hi all- This seems to work. Paste this in B9 and copy down:
    =IF(ISFORMULA(C9),"-",C9/$B$6*100)

    ...and this in C9 and copy down:
    =IF(ISFORMULA(B9),"-",$B$6*B9/100)

    Please click the Add Reputation star below any helpful posts, and if you have your answer, mark your thread as SOLVED (Thread Tools up top). Thanks!-Lee
    Gives me theres problem with this formula error. And I don't think this this is going to work as I want all data in one table?

  12. #12
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    43,984

    Re: Bidirectional percentage- weight formula?

    So if it isn't what you want... what DO you want? You need to explain. There aren't many mind readers here...

  13. #13
    Registered User
    Join Date
    08-07-2017
    Location
    .
    MS-Off Ver
    2016
    Posts
    11

    Re: Bidirectional percentage- weight formula?

    Quote Originally Posted by Glenn Kennedy View Post
    So if it isn't what you want... what DO you want? You need to explain. There aren't many mind readers here...
    One table. Typed percentage of total weight changes values in the weight in grams column and vice versa, typed grams changes percentage.
    Your solution is good, but have to use drop down list.

  14. #14
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Bidirectional percentage- weight formula?

    Quote Originally Posted by naubusan View Post
    One table. Typed percentage of total weight changes values in the weight in grams column and vice versa, typed grams changes percentage.
    This is exactly how my formulae behaved. Both cells are formulas, so initially both yield "-". When you type something in either cell and press enter, it no longer contains a Formula, so the other cell calculates appropriately. Barring VBA, this is (I think) the only way to achieve your goal.

    Wait, is B6 amount FIXED, or is it summing all the weights in column C, meaning the WHOLE percentages column must change whenever it does? The latter would explain why you're getting a circular reference problem.
    Last edited by leelnich; 08-07-2017 at 09:51 AM.

  15. #15
    Registered User
    Join Date
    08-07-2017
    Location
    .
    MS-Off Ver
    2016
    Posts
    11

    Re: Bidirectional percentage- weight formula?

    Quote Originally Posted by leelnich View Post
    This is exactly how my formulae behaved. Both cells are formulas, so initially both yield "-". When you type something in either cell and press enter, it no longer contains a Formula, so the other cell calculates appropriately. Barring VBA, this is (I think) the only way to achieve your goal.
    I had to change commas to semicolons to get that working, different excel versions I think.
    Yes this way it works but overwrites the formula.

  16. #16
    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,409

    Re: Bidirectional percentage- weight formula?

    No, not different Excel versions, but different locales: where the UK, US and Australasia use the comma, other parts of the world use semi-colons. That's a broad brush I've used, but essentially where a comma is used as a decimal separator, semi-colons are used as separators in formulae. Where a decimal point is used, there a comma is used in formulae. That's why we ask you for your location: unfortunately, your profile entry is not very helpful.

  17. #17
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Bidirectional percentage- weight formula?

    Thanks @AliGW, problem explained!
    Quote Originally Posted by naubusan View Post
    Yes this way it works but overwrites the formula.
    The overwrite is unavoidable, yes? If you wish to switch an "entered" cell back to formula, you'll have to copy it from another cell. Of course, you could use VBA's Worksheet_Change event to respond to entries in either column by calculating the corresponding values, eliminating the overwrite problem.
    Last edited by leelnich; 08-07-2017 at 10:21 AM.

  18. #18
    Registered User
    Join Date
    08-07-2017
    Location
    .
    MS-Off Ver
    2016
    Posts
    11

    Re: Bidirectional percentage- weight formula?

    Quote Originally Posted by leelnich View Post
    Problem explained!The overwrite is unavoidable with worksheet formulas, yes? If you wish to switch an "entered" cell back to formula, you'll have to copy it from another cell. Of course, if you use VBA, it could respond to entries in either column by calculating the corresponding values, eliminating the overwrite problem.
    Yes that is what I try to achieve.

  19. #19
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Bidirectional percentage- weight formula?

    This should work. It's already part of the attached workbook.
    Please Login or Register  to view this content.
    NOTES
    This code is worksheet-specific. To use it with another workbook/worksheet:
    1) Open the relevant workbook.
    2) Right-click on the relevant worksheet tab and select View Code.
    3) Paste the code from above in the Worksheet Module that appears.
    4) Close the Visual Basic Editor window. This returns you to Excel.

    That's it! Now save the workbook as a Macro-Enabled (.xlsm) file:
    1) Select Save As from the File tab on the command ribbon.
    2) Choose a folder
    3) Click in the Save as type: box
    4) Select Excel Macro-Enabled Workbook
    5) Click Save

    Note that this is a BRAND NEW FILE. It has the same NAME as the old version, but a different FILE EXTENSION (.xlsm)
    To avoid confusion, you should delete the old version, which has a .xlsx file extension.
    Attached Files Attached Files
    Last edited by leelnich; 08-07-2017 at 11:59 AM.

  20. #20
    Registered User
    Join Date
    08-07-2017
    Location
    .
    MS-Off Ver
    2016
    Posts
    11

    Re: Bidirectional percentage- weight formula?

    Thank you leelnich very much! Just perfect!

  21. #21
    Registered User
    Join Date
    08-07-2017
    Location
    .
    MS-Off Ver
    2016
    Posts
    11

    Re: Bidirectional percentage- weight formula?

    Is this script possible to get working so, when B6 value is changed that other values updates automatically?

  22. #22
    Forum Expert leelnich's Avatar
    Join Date
    03-20-2017
    Location
    Delaware, USA
    MS-Off Ver
    Office 2016
    Posts
    2,807

    Re: Bidirectional percentage- weight formula?

    Yes, but first we need to examine the underlying logic of this entire approach.
    1) In this context, Percentages should always add to 100. If one is changed, others must change to compensate.
    2) Changing an individual weight should change Total Weight, unless other weights are adjusted to compensate.
    3) Given the above, changing one individual weight or one percentage should cause recalculation of the ENTIRE TABLE.

    None of the solutions - VBA or worksheet function - offered so far truly address these issues. I think you must define HOW these adjustments should be made in both cases.
    Last edited by leelnich; 08-07-2017 at 01:57 PM.

  23. #23
    Registered User
    Join Date
    08-07-2017
    Location
    .
    MS-Off Ver
    2016
    Posts
    11

    Re: Bidirectional percentage- weight formula?

    Changing total weight should change whole table. Changing Ingredient percentage or weight only changes that row.
    This is used to calculate spices to certain amount of food (total weight). Sometimes amount is given grams to certain amount of food and sometimes spices percentage per certain amount of food. Sorry, when not native english speaker, explaining this is difficult

  24. #24
    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,409

    Re: Bidirectional percentage- weight formula?

    The thread is marked as solved - is it???

+ 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] Running Formula for Total Weight Loss Percentage
    By ExcelDummy77 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-06-2016, 10:58 AM
  2. Help calculating the total weight lost from starting weight D1
    By rgainey201 in forum Excel - New Users/Basics
    Replies: 7
    Last Post: 12-31-2014, 06:16 PM
  3. Auto Calculate Shipping Weight/Cartons and Package Weight.
    By suhailsiddiqui09 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-27-2013, 06:48 AM
  4. Total novice fishing weight percentage calculator
    By garryrobson85 in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 04-21-2013, 05:22 PM
  5. Replies: 10
    Last Post: 01-28-2013, 07:41 PM
  6. Weight loss line chart to monitor weight loss progress
    By S Fox in forum Excel Charting & Pivots
    Replies: 6
    Last Post: 11-08-2005, 01:15 PM
  7. [SOLVED] Need help w/ Weight Formula
    By Tom in forum Excel General
    Replies: 3
    Last Post: 03-04-2005, 02:06 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