+ Reply to Thread
Results 1 to 8 of 8

Conditional formatting / VBA, based on selected time range

  1. #1
    Valued Forum Contributor
    Join Date
    10-17-2007
    Location
    Tasmania, Australia
    MS-Off Ver
    2019, 365(v2310)
    Posts
    366

    Conditional formatting / VBA, based on selected time range

    Good Morning all,

    Time again to ask the gurus another question.

    Attached is a workbook. I have manually highlighted the cells to give you an idea of what I would like the outcome to be.

    This is a bit like telling you guru's to suck eggs but I thought I would detail it as much as I could.

    Anyway.....

    Moonah OPS sheet.
    In Row 5(Shift times), under the drop down menu in cells B5:J5, there is a range of Shift times.
    And for the purpose of this I have selected
    B5 as 0800:1621, manually highlighted B11:B27
    C5 as 06:00, manually highlighted C7:C24
    D5 as 07:00:1521, manually highlighted B11:B27
    E5:I55(RDO, REC, SICK, Travel) can remain as manual input if it is to much to work out.

    Is it possible or just a pipe dream, to use some method to automatically highlight a range of cells based on the C5:J5 'time'?

    If the time is an actual shift time, the colour will be green and dark green writing as default, then we can allocate jobs/training/meetings and manually colour them.

    What ya'll think?

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

    Re: Conditional formatting / IF based on selected time range

    hi russkris. it would be good to update your MS off Ver in your profile so that we can give you the more new & efficient formulas. select the range you want to apply to (say from B7:J30)
    in Excel 2007 & above, go to Home -> Conditional Formatting -> New Rule -> Use a formula to determine which cells to format -> Format values where this formula is true:
    in Excel 2003, go to Format -> Conditional Formatting -> Formula is:
    =AND($A7>=--LEFT(B$5,5),$A7<=--RIGHT(B$5,5))

    make it the light green you did in Column B:D. i think you illustrated that well, so no worries about letting us suck eggs. the rest are a little confusing to me though. assuming the other texts like RDO, REC LEAVE, etc means to highlight grey for 8 am to 4:30 pm, then repeat the steps & put in this formula:
    =AND($A7>=TIME(8,,),$A7<=TIME(16,30,),OR(B$5="RDO",B$5="REC LEAVE",B$5="SICK LEAVE",B$5="Pers Leave"))

    TRAVEL would be slightly the same;
    =AND($A7>=TIME(8,,),$A7<=TIME(16,30,),B$5="TRAVEL")

    about this:
    If the time is an actual shift time, the colour will be green and dark green writing as default, then we can allocate jobs/training/meetings and manually colour them.
    i don't know what it means. actual shift time referring to what you did in Column B:D? you can use dark green as the font in the Conditional Formatting window. but note that the Conditional Formatting supersedes the normal formatting. if it's dark green, you cannot manually overwrite it by formatting

    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
    Valued Forum Contributor
    Join Date
    10-17-2007
    Location
    Tasmania, Australia
    MS-Off Ver
    2019, 365(v2310)
    Posts
    366

    Re: Conditional formatting / IF based on selected time range

    Quote Originally Posted by benishiryo View Post
    i don't know what it means. actual shift time referring to what you did in Column B:D? you can use dark green as the font in the Conditional Formatting window. but note that the Conditional Formatting supersedes the normal formatting. if it's dark green, you cannot manually overwrite it by formatting
    Hi benishiryo,

    Firstly, Thank you for taking the time to help.
    In Row 5(Shift times), under the drop down menu in cells B5:J5, there is a range of Shift times, meaning anything time based option eg: 06:00-14:21, not REC, etc.

    So it seems like conditional format wont work. What I would like to do is select say 06:00-14:21 in cell C5 for an employee and a CF or marco will automatically colour cells from C7:C24

  4. #4
    Valued Forum Contributor
    Join Date
    10-17-2007
    Location
    Tasmania, Australia
    MS-Off Ver
    2019, 365(v2310)
    Posts
    366

    Re: Conditional formatting / IF based on selected time range

    Hi benishiryo,

    Sorry if my last post offended you in any way. To further clarify the above and your concerns in the PM.

    Please see attached. Daysheet DAY MONTH YEAR template - Highlight2.xlsx

    I haven't added the TRAVEL CFormatting yet.

    My meaning for the previous post. If I select, say, 08:00-16:21, the CF works great except I can not "re-colour" the cells (See example Column E), as you said CFormatting over rules anything else, hence the comment of
    So it seems like conditional format wont work.
    I probably should have added that extra detail in the original post, my apologies for that.


    I hope this clarifies it slightly better for you.

    Again, apologies and Thank you greatly.

  5. #5
    Valued Forum Contributor
    Join Date
    10-17-2007
    Location
    Tasmania, Australia
    MS-Off Ver
    2019, 365(v2310)
    Posts
    366

    Re: Conditional formatting / VBA, based on selected time range

    Could a MOD please move this to the VBA forum with a link here?

    Attached the updated workbook for the VBA gurus.

    Daysheet DAY MONTH YEAR template - Highlight3.xlsx

  6. #6
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,936

    Re: Conditional formatting / VBA, based on selected time range

    I will move it for you
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  7. #7
    Valued Forum Contributor
    Join Date
    10-17-2007
    Location
    Tasmania, Australia
    MS-Off Ver
    2019, 365(v2310)
    Posts
    366

    Re: Conditional formatting / VBA, based on selected time range

    Thank you FDibbins. Greatly appreciated.


    benishiryo has been PM'd me for more information and asked that I put the following information.


    Here is a normal kind of edit.

    Untitled.jpg

    Once I have selected the shift time for the officer(Row 5(B5:J5)), I manually colour it with a pre-configured Excel style(green)
    Then go about manually allocating any jobs/duties for each officer, So you can see on the 06:00 start(Column I), the officer is doing "Express Post", I manually highlight the cells I7:I10, as the task usually takes 2 hours. So If an officer remains green, they may be available to do a urgent booking.

    So yes there will be blank cells and cells with text
    Hope the added information will help.

  8. #8
    Valued Forum Contributor
    Join Date
    10-17-2007
    Location
    Tasmania, Australia
    MS-Off Ver
    2019, 365(v2310)
    Posts
    366

    Re: Conditional formatting / VBA, based on selected time range

    Bump

    Any idea if a marco can do this?

+ 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. Replies: 3
    Last Post: 08-13-2013, 09:44 AM
  2. Conditional Formatting via VBA: Change formatting in range based on value of each cell
    By ralphjmedia in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-12-2013, 10:37 AM
  3. Conditional Formatting - Grey Out and Lock A range based on a cell value in that range
    By Excelgnome in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-14-2012, 07:31 PM
  4. Conditional Formatting Based on Time Window
    By sdoremus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-07-2008, 04:48 PM
  5. Conditional formatting based on time
    By sharkey in forum Excel General
    Replies: 2
    Last Post: 12-24-2007, 02:13 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