+ Reply to Thread
Results 1 to 4 of 4

Auto Calculation depending on value in one cell

  1. #1
    Registered User
    Join Date
    10-31-2011
    Location
    Singapore
    MS-Off Ver
    Microsoft 365 (Windows 10)
    Posts
    62

    Auto Calculation depending on value in one cell

    Hi,

    Is there a macro so that a specifice calculation is automatically done depending on the letter in a specific cell?

    Ie, if i have the letter "B" in cell E8, then the sum in R8 = L8+O8+P8
    but if i have the letter "S" in cell E8, then the sum in R8= L8-O8-P8

    Ideally this would be applied for the whole column E, so regardless of specific cells, the calculations in column R is according to the letter in the corresponding row/cell

    ie, this is also applied to R11, R14 and R22 depending on the letters in E11, E14, E22, but without having to go through and manually input the calculation.

    Hope that makes sense!

    Any help most appreciated as always.

    Best,
    MM

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: Auto Calculation depending on value in one cell

    One way:

    =IF(AND(E8<>"B",E8<>"S"),"",L8+IF(E8="B",(O8+P8),IF(E8="S",(-O8-P8),"")))

    Or:

    =IF(AND(E8<>"B",E8<>"S"),"",IF(E8="B",(L8+O8+P8),IF(E8="S",(L8+-O8-P8),"")))


    Regards, TMS
    Last edited by TMS; 01-21-2013 at 05:01 AM.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-31-2011
    Location
    Singapore
    MS-Off Ver
    Microsoft 365 (Windows 10)
    Posts
    62

    Re: Auto Calculation depending on value in one cell

    Hi TMS,

    Thanks, didn't work at first, so i tweaked what you put and just went with =IF(A1="B",(B1+C1+D1),IF(A1="S",(B1-C1-D1)))!

    Thanks!!!

    MM

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,445

    Re: Auto Calculation depending on value in one cell

    OK. I'm sure it worked when I tested it. Of course, it was using the rows and columns from the OP

    Whatever, I'm glad you have a solution/ Note that the formula you have used will return FALSE if A1 is not "B" or "S".


    Regards, TMS



    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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