+ Reply to Thread
Results 1 to 5 of 5

Modifying an IF formula to exclude fields with a certain criteria

  1. #1
    Registered User
    Join Date
    11-23-2021
    Location
    Europe
    MS-Off Ver
    2019
    Posts
    3

    Question Modifying an IF formula to exclude fields with a certain criteria

    Hello.

    I have created a formula in Excel for my workplace, which is meant to alert when a person exceeds 32 work hours in a week (7 consecutive days). The alert says "Ok" when there isn't an occurrence of 32+ hours in 7 consecutive days, and it says "Over 32" when it does occur.

    Screenshot 2021-11-23 161036.png

    The yellow row are the days of the month, below are the work hours, and under those are the indicators of a shift (1 being morning, 2 being afternoon, and A and B being examples for absence or vacation). I would like the formula for Over/Under 32 to leave out the days marked with "B", so it won't add the hours from the cell above the "B" in the total calculation. For example, if there are 38 work hours in a 7-day window, but 8 of those come from a "B" shift, it should just count it as 30 and alert "Ok"

    This is the formula used as of now. It's a bit sloppy, but it works just fine. Is it possible to somehow add my criteria to it?

    =IF(SUM(B10:H10)>32;"Over 32"; IF(SUM(C10:I10)>32;"Over 32"; IF(SUM(D10:J10)>32;"Over 32"; IF(SUM(E10:K10)>32;"Over 32"; IF(SUM(F10:L10)>32;"Over 32"; IF(SUM(G10:M10)>32;"Over 32"; IF(SUM(H10:N10)>32;"Over 32"; IF(SUM(I10:O10)>32;"Over 32"; IF(SUM(J10:P10)>32;"Over 32"; IF(SUM(K10:Q10)>32;"Over 32"; IF(SUM(L10:R10)>32;"Over 32"; IF(SUM(M10:S10)>32;"Over 32"; IF(SUM(N10:T10)>32;"Over 32"; IF(SUM(O10:U10)>32;"Over 32"; IF(SUM(P10:V10)>32;"Over 32"; IF(SUM(Q10:W10)>32;"Over 32"; IF(SUM(R10:X10)>32;"Over 32"; IF(SUM(S10:Y10)>32;"Over 32"; IF(SUM(T10:Z10)>32;"Over 32"; IF(SUM(U10:AA10)>32;"Over 32"; IF(SUM(V10:AB10)>32;"Over 32"; IF(SUM(W10:AC10)>32;"Over 32"; IF(SUM(X10:AD10)>32;"Over 32"; IF(SUM(Y10:AE10)>32;"Over 32"; IF(SUM(Z10:AF10)>32;"Over 32";"Ok")))))))))))))))))))))))))

    Here's the Workbook attached as well.
    Book1.xlsx

    Thank you in advance.
    Last edited by spacelord69; 11-24-2021 at 02:20 PM.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,942

    Re: Modifying an IF formula to exclude fields with a certain criteria

    Change your SUM(B10:H10)>32 to SUMIF(B11:H11;"<>B";B10:H10)

    But instead of using your very large formula, enter this intto cell H12

    =SUMIF(B11:H11;"<>B";B10:H10)

    and copy to the right to the column with 31 as the header. Then use a final formula

    =IF(MAX(H12:AF12)>32;"Over 32"; "Ok")

    You can format row 12 using special ;;; to hide the extra formulas - it will just be easier to maintain
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    11-23-2021
    Location
    Europe
    MS-Off Ver
    2019
    Posts
    3

    Re: Modifying an IF formula to exclude fields with a certain criteria

    Thank you! It's exactly what I was looking for.

    Just one more thing - is it possible to exclude couple more symbols besides B - like A or C. How would that formula look like?

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,942

    Re: Modifying an IF formula to exclude fields with a certain criteria

    Use this to exclude more than one symbol

    =SUMIFS(B10:H10;B11:H11;"<>B";B11:H11;"<>A")

    You can expand it beyond 2 symbols, like

    =SUMIFS(B10:H10;B11:H11;"<>B";B11:H11;"<>A";B11:H11;"<>Whatever")

    Or if you have specific symbols to look for, instead of exclude:

    =SUM(SUMIF(B11:H11;{"W";"Z"};B10:H10))
    Last edited by Bernie Deitrick; 11-23-2021 at 02:04 PM.

  5. #5
    Registered User
    Join Date
    11-23-2021
    Location
    Europe
    MS-Off Ver
    2019
    Posts
    3

    Re: Modifying an IF formula to exclude fields with a certain criteria

    Thank you very much Bernie. This solved everything.
    Added reputation.

+ 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] Modify countifs formula to exclude certain criteria
    By lar9149 in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 08-02-2021, 08:43 PM
  2. [SOLVED] Modifying VBA to exclude a given string
    By CDandVinyl in forum Word Programming / VBA / Macros
    Replies: 4
    Last Post: 05-13-2021, 09:33 PM
  3. [SOLVED] Dax Formula to exclude specific criteria
    By Rainbow_1980 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-26-2019, 08:45 AM
  4. Replies: 4
    Last Post: 08-06-2018, 07:54 AM
  5. Replies: 3
    Last Post: 04-21-2015, 07:45 AM
  6. Formula to Exclude lines that dont match criteria
    By chrismike in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-27-2013, 07:18 PM
  7. Help Modifying a form created with VBA (4 new fields)
    By simjambra in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-13-2009, 12:24 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