+ Reply to Thread
Results 1 to 10 of 10

Conditional Formatting Using MOD and AND formulas

  1. #1
    Registered User
    Join Date
    04-23-2013
    Location
    Shrewsbury, England
    MS-Off Ver
    Excel 2007
    Posts
    44

    Conditional Formatting Using MOD and AND formulas

    Greetings, trying to conditional format a time entry (start time) if time difference of the preceding (stop time) time entry is less than 8 hrs. Used MOD(B5-H4,1) which gives me the time difference. Trying to use AND(>1,<8) which gives me the 8 hr limit but not sure how I use the conditional drop down to get my original time entry to change to red as per my starting desire. Can anyone make sense of what I am trying to achieve and better still come up with a workable solution? Many thanks as always.

    Eg
    Start Stop Hrs Worked
    08:00 21:00 12:00
    03:00 09:00 06:00

    In the example I am trying to get 03:00 go red on condition it is less than 8hrs between the stop time 21:00 and 03:00 start time. There is a month's worth of start/stop times.
    Last edited by Harrytheb; 11-10-2015 at 09:42 AM.

  2. #2
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    30,751

    Re: Conditional Formatting Using MOD and AND formulas

    Can you post a small file illustrating what you require.

  3. #3
    Registered User
    Join Date
    04-23-2013
    Location
    Shrewsbury, England
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: Conditional Formatting Using MOD and AND formulas

    I have updated the original post to try to better explain what I am after. The start and stop times cover a month in this instance, I have just given an example.

    Thanks for looking, appreciate your help. H
    Last edited by Harrytheb; 11-09-2015 at 06:23 PM.

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Conditional Formatting Using MOD and AND formulas

    If this is your data...

    Data Range
    A
    B
    C
    1
    Start
    Stop
    Hrs Worked
    2
    8:00
    21:00
    12:00
    3
    3:00
    9:00
    6:00


    Use a formula like this for the conditional formatting:

    =AND(COUNT(A2,C2)=2,C2<TIME(8,0,0))
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Registered User
    Join Date
    04-23-2013
    Location
    Shrewsbury, England
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: Conditional Formatting Using MOD and AND formulas

    Tried this and I could not get it to format. Trying to format the cell not based on it's value but the formula, so not sure which of the options on the drop downs I should be using.

  6. #6
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Conditional Formatting Using MOD and AND formulas

    Works for me.

    Here's a small sample file that demonstrates this.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    04-23-2013
    Location
    Shrewsbury, England
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: Conditional Formatting Using MOD and AND formulas

    Thank you for your patience. I do not understand the syntax of the formula, would you put it in layman's terms? I have attached a portion of the file that I am building so that you can have a better idea. The columns that I am working with are greyed out.

    Harrytheb2.xlsxExample1.xlsx

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Conditional Formatting Using MOD and AND formulas

    I didn't download your files.

    After reading the top post again I think I have misunderstood what you want to do.

    Quote Originally Posted by Harrytheb View Post

    Eg
    Start Stop Hrs Worked
    08:00 21:00 12:00
    03:00 09:00 06:00

    In the example I am trying to get 03:00 go red on condition it is less than 8hrs between the stop time 21:00 and 03:00 start time.
    So, it's based on the stop time from the row above and the start time from the row below? Is that correct?

  9. #9
    Registered User
    Join Date
    04-23-2013
    Location
    Shrewsbury, England
    MS-Off Ver
    Excel 2007
    Posts
    44

    Re: Conditional Formatting Using MOD and AND formulas

    Hi Tony, I have changed the post a couple of times for clarity. You are correct, it is the stop time from the row above and the start time from the next row.

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Conditional Formatting Using MOD and AND formulas

    Based on the Harrytheb2.xlsx file...

    Select the range B11:B19 starting from B11.

    Conditional formatting
    Formula:

    =AND(COUNT(H10,B11)=2,MOD(B11-H10,1)<TIME(8,0,0))

+ 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] conditional formatting with formulas
    By barelyadraft in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 10-18-2012, 02:57 PM
  2. Conditional formatting using formulas
    By masond3 in forum Excel General
    Replies: 18
    Last Post: 11-14-2011, 08:53 AM
  3. Conditional formatting using formulas
    By masond3 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-13-2011, 10:27 PM
  4. Replies: 1
    Last Post: 09-14-2010, 03:45 AM
  5. Excel 2007 : Conditional Formatting With Formulas
    By krt777 in forum Excel General
    Replies: 5
    Last Post: 11-04-2008, 04:57 AM
  6. Conditional Formatting for formulas
    By Mary Frances in forum Excel General
    Replies: 1
    Last Post: 01-04-2008, 06:15 PM
  7. [SOLVED] Conditional Formatting for Formulas
    By Murat Gordeslioglu in forum Excel General
    Replies: 3
    Last Post: 06-22-2006, 04:10 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