+ Reply to Thread
Results 1 to 5 of 5

how to simplify the long formula

  1. #1
    Registered User
    Join Date
    08-25-2008
    Location
    Abu Dhabi, UAE
    Posts
    3

    how to simplify the long formula

    hi, i am new here in this forum, i was just wondering if you could help me with my formula. what i am trying to do is to get the total overtime hours of employees for the whole month. here is the formula i used but actually this one is only for seven days
    "=IF(AND(WEEKDAY($B$4)>=6,OR(C5>=8,C5<8)),C5,IF(C5<=8,0,(C5-8)))+IF(AND(WEEKDAY(E$4)>=6,OR(F5>=8,F5<8)),F5,IF(F5<=8,0,(F5-8)))+IF(AND(WEEKDAY(H$4)>=6,OR(I5>=8,I5<8)),I5,IF(I5<=8,0,(I5-8)))+IF(AND(WEEKDAY(K$4)>=6,OR(L5>=8,L5<8)),L5,IF(L5<=8,0,(L5-8)))+IF(AND(WEEKDAY(N$4)>=6,OR(O5>=8,O5<8)),O5,IF(O5<=8,0,(O5-8)))+IF(AND(WEEKDAY(Q$4)>=6,OR(R5>=8,R5<8)),R5,IF(R5<=8,0,(R5-8)))+IF(AND(WEEKDAY(T$4)>=6,OR(U5>=8,U5<8)),U5,IF(U5<=8,0,(U5-8)))"

    i am considering fridays and saturdays as overtime and those exceeding 8 hours in weekdays.

    any help is appreciated, thanks

  2. #2
    Forum Expert
    Join Date
    12-23-2006
    Location
    germany
    MS-Off Ver
    XL2003 / 2007 / 2010
    Posts
    6,326
    Hi, and welcome to the board,

    please refrain from starting a thread within another thread . See our forum rules. I therefore started a thread for you.

    As for your problem maybe this site will help

    Cheers

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Why use OR(C5>=8,C5<8)?

    This is always TRUE.

    Your spreadsheet design means that any formulas you use will probably be more complex than necessary. It's much easier if you have one record per row, e.g. dates in A2:A32 and corresponding hours in B2:B32

    Having said that......for your setup, assuming dates are every 3rd cell from B4 to CN4 try this formula

    =SUM(IF(MOD(COLUMN(B4:CN4)-COLUMN(B4),3)=0,IF(WEEKDAY(B4:CN4)>5,C5:CO5,IF(C5:CO5>8,8-C5:C5))))

    also confirmed with CTRL+SHIFT+ENTER

    Note: to confirm with CTRL+SHIFT+ENTER select cell with formula, press F2 key, hold down CTRL and SHIFT keys and press ENTER so that curly braces like { and } appear around the formula in the formula bar

  4. #4
    Registered User
    Join Date
    08-25-2008
    Location
    Abu Dhabi, UAE
    Posts
    3
    thanks for the formula youve given to me. after analyzing it and made some small changes, it works perfectly.

    "=SUM(IF(MOD(COLUMN(B4:CP4)-COLUMN(B4),3)=0,IF(WEEKDAY(B4:CP4)>5,C5:CP5,IF(C5:CP5>8,C5:CP5-8))))"

    again, thank you!

  5. #5
    Registered User
    Join Date
    08-25-2008
    Location
    Abu Dhabi, UAE
    Posts
    3
    one more thing, what if one of the columns contain text value (example "leave",etc). i tried the same formula but returns with error.

    please help

+ 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. Hide messagbox
    By tqm1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-01-2007, 01:30 AM
  2. Copying formula in long column
    By seanof30306 in forum Excel General
    Replies: 1
    Last Post: 06-20-2007, 03:01 PM
  3. Replies: 1
    Last Post: 06-20-2007, 12:04 PM
  4. Formula too long problem.
    By zipp in forum Excel General
    Replies: 4
    Last Post: 06-15-2007, 06:32 PM
  5. Sorting Macro
    By Dohko in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 04-16-2007, 08:04 AM

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