+ Reply to Thread
Results 1 to 3 of 3

IF and ADD formula

  1. #1
    Registered User
    Join Date
    01-14-2014
    Location
    Bristol, United Kingdom
    MS-Off Ver
    Excel 2010
    Posts
    1

    IF and ADD formula

    Hi I am working on a timesheet for work which is in place and works fine.

    Hidden away I have a formula for everyday of the year which looks into to the top three rows of every day and pick out if a job code is 27 or 28

    This is my formula:
    =-IF(AND($B$57>=27,$B$57<=28),$E$57)+-IF(AND($B$58>=27,$B$58<=28),$E$58)+-IF(AND($B$59>=27,$B$59<=28),$E$59)

    However although I have locked the formula down, if someone cuts and pastes an item into B57 for example the formula changes to #Ref and I have to go in and change the formula back again.


    Is there a way to stop this formula from changing when someone cuts and pastes into a cell which is included in the formula.

    Any help would be appreciated.

    Neil

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: IF and ADD formula

    welcome to the forum, Neil. a few things to note just for learning's sake
    1. if job code is only 27 or 28, and not in decimals, then use OR instead
    =-IF(OR($B$57=27,$B$57=28),$E$57)+-IF(OR($B$58=27,$B$58=28),$E$58)+-IF(OR($B$59=27,$B$59=28),$E$59)

    2. +- is equivalent to just minus
    =-IF(OR($B$57=27,$B$57=28),$E$57)-IF(OR($B$58=27,$B$58=28),$E$58)-IF(OR($B$59=27,$B$59=28),$E$59)

    3. and it looks like you can use something shorter:
    =-SUMIFS(E57:E59,B57:B59,">=27",B57:B59,"<=28")
    or:
    =-SUM(SUMIFS(E57:E59,B57:B59,{"27","28"}))

    4. to ensure the REF error doesnt happen, you could protect the sheet or use:
    =-SUM(SUMIFS(E57:E59,INDIRECT("B57:B59"),{"27","28"}))

    do the same for E57:E59 if you need to

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Forum Expert martindwilson's Avatar
    Join Date
    06-23-2007
    Location
    London,England
    MS-Off Ver
    office 97 ,2007
    Posts
    19,320

    Re: IF and ADD formula

    =-if(or(index($b:$b,57)={27,28}),$e$57)-if(or(index($b:$b,58)={27,28}),$e$58)-if(or(index($b:$b,59)={27,28}),$e$59)
    "Unless otherwise stated all my comments are directed at OP"

    Mojito connoisseur and now happily retired
    where does code go ?
    look here
    how to insert code

    how to enter array formula

    why use -- in sumproduct
    recommended reading
    wiki Mojito

    how to say no convincingly

    most important thing you need
    Martin Wilson: SPV
    and RSMBC

+ 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. how to hide formula in formula box, view lookup result in formula box?
    By vengatvj in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-14-2013, 04:06 PM

Tags for this Thread

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