+ Reply to Thread
Results 1 to 2 of 2

VBA Conditional Format to Highlight Cells that have a 13:00 as part of a date (any Date)

Hybrid View

  1. #1
    Registered User
    Join Date
    05-13-2024
    Location
    Reno,nv
    MS-Off Ver
    365
    Posts
    13

    Question VBA Conditional Format to Highlight Cells that have a 13:00 as part of a date (any Date)

    Hello all,

    I am looking to automate some conditional formatting based on a cell having a date value that includes 13:00. So 5/7/2024 13:00 or 5/9/2024 13:00 would highlight but 5/9/2024 17:00 would not. Below is the code I have. Kinda new to coding.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Dim Range1 As Range

    Set Range1 = Worksheets("Cover").Range("K11:K24")

    For Each Cell In Range1

    If Cell.Value Like "*13:00" Then
    Cell.Interior.ColorIndex = 6

    Else
    Cell.Interior.Color = xlNone

    End If

    Next

    End Sub

  2. #2
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454

    Re: VBA Conditional Format to Highlight Cells that have a 13:00 as part of a date (any Dat

    Hi,

    If you must use VBA for this, the following may help,

    If IsDate(Cell.Value) And Hour(Cell.Value) = 13 And Minute(rell.Value) = 0 Then
    but i would recommend the native conditional formatting, using a formula like this:

    Formula: copy to clipboard
    =AND(HOUR(A1)=13,MINUTE(A1)=0)
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

+ 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 format : Highlight row if column F has a date that is 60 days past or more
    By DarkPurpleInk in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-14-2022, 12:37 PM
  2. Replies: 3
    Last Post: 12-06-2019, 02:55 PM
  3. Replies: 6
    Last Post: 08-22-2019, 07:18 PM
  4. [SOLVED] Splitting date fails for a part of date column due to different cell format
    By Moriexcel in forum Excel Programming / VBA / Macros
    Replies: 32
    Last Post: 11-21-2014, 01:00 PM
  5. Replies: 4
    Last Post: 05-15-2014, 04:39 PM
  6. [SOLVED] Conditional Format to highlight cell based on corresponding date..
    By Vikestand in forum Excel General
    Replies: 4
    Last Post: 07-24-2013, 10:48 AM
  7. Replies: 1
    Last Post: 09-30-2012, 03:01 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