+ Reply to Thread
Results 1 to 8 of 8

Cell value based on multiple conditions

  1. #1
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,054

    Smile Cell value based on multiple conditions

    I need to create a macro that will calculate a value based on the contents of multiple cells. Looking at the example attached, if columns A and/or B (employee ID and name) are empty, then allowable OT (G) should be 0. If either have data, then if Stage (F) is CAN, G should be 20. If Stage is FAS or FAR, G should be 10.

    I'm not very savvy with IF statements, which is how I imagine this can be done, and I don't know if this would be easier to do as a macro or as a formula within G. Since the contents of the of the cells will be changing on a weekly basis, I'd prefer the formula to only be there if there is content on the line, so we don't have nulls showing.

    I appreciate any help I can get.
    Attached Files Attached Files
    Last edited by jomili; 02-23-2010 at 12:48 PM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Cell value based on multiple conditions

    Irrespective of approach, does this formula produce the results you want?

    =IF(COUNTA(A2:B2)=0,0,IF(F2="CAN",20,IF(OR(F2="FAS",F2="FAR"),10)))

  3. #3
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,054

    Re: Cell value based on multiple conditions

    Stephen,

    Yes! Your formula works perfectly! Thank you!

    Now ideally I'd like to incorporate this into the macro I'm already running, whereby I select the data you've seen from another workbook and paste it into the worksheet example you saw. I would like the formula to derive the allowable hours and then paste those values in to column G. Any ideas how to accomplish that piece?

  4. #4
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Cell value based on multiple conditions

    This will put the formula in G with code and then replace with values- not sure I follow what else you want to do.
    Please Login or Register  to view this content.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Cell value based on multiple conditions

    Use the recorder to record you putting the formula into the correct cell at the correct time, let the formula do the math for you. Makes the macro a lot easier to design.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  6. #6
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,054

    Re: Cell value based on multiple conditions

    Stephen,

    You deserve your title of forum guru. I think you've given me everything I could every ask for in terms of this little function, and I thank you from the bottom of my heart. If there's any way i can ever repay the favor just let me know.

    Thank you!

  7. #7
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Cell value based on multiple conditions

    My pleasure, glad it worked.

    JB makes a good point - the macro recorder is your friend.

  8. #8
    Valued Forum Contributor
    Join Date
    12-02-2009
    Location
    Austin, Tx
    MS-Off Ver
    Office 365 64-Bit, 2108, build 14326.21018
    Posts
    4,054

    Re: Cell value based on multiple conditions

    JB,
    Thanks for your comment. I try to use the macro recorder every time I can, and it's helped me out lots. Thanks for suggesting it.

+ 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