+ Reply to Thread
Results 1 to 5 of 5

Macro to highlight cell based on value in below row

Hybrid View

  1. #1
    Registered User
    Join Date
    08-04-2015
    Location
    a
    MS-Off Ver
    a
    Posts
    4

    Macro to highlight cell based on value in below row

    Hi,

    I am looking for a macro to highlight a cell based on the rule it has a blank cell below.

    The data series looks like the below and has 15,000 rows:

    Cells.png

    Thanks in advance.

  2. #2
    Forum Contributor Obsessed's Avatar
    Join Date
    05-22-2013
    Location
    Cincinnati, Ohio
    MS-Off Ver
    Excel 365
    Posts
    215

    Re: Macro to highlight cell based on value in below row

    Try:

    Sub Highlight()
    
    Dim LR As Long, R As Long
    
    LR = ActiveSheet.Range("A" & ActiveSheet.UsedRange.Rows.Count + 2).End(xlUp).Row
    
    For R = 1 To LR
    If Cells(R, 1) <> "" And Cells(R + 1, 1) = "" Then
        With Cells(R, 1).Interior
            .Pattern = xlSolid
            .PatternColorIndex = xlAutomatic
            .Color = 65535
            .TintAndShade = 0
            .PatternTintAndShade = 0
        End With
    End If
    Next R
    
    End Sub
    Want to show appreciation for the help you received from a member? Give them reps by clicking the bottom left of their post!

  3. #3
    Registered User
    Join Date
    08-04-2015
    Location
    a
    MS-Off Ver
    a
    Posts
    4

    Re: Macro to highlight cell based on value in below row

    Perfect! Thanks!

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,961

    Re: Macro to highlight cell based on value in below row

    try this:
    Option Explicit
    
    Sub HiLite()
        Dim lr As Long
        Dim i As Long
        lr = Range("A" & Rows.Count).End(xlUp).Row
        
        Application.ScreenUpdating = False
        For i = 1 To lr
        If IsEmpty(Range("A" & i)) Then
            Range("A" & i - 1).Interior.ColorIndex = 37
        End If
        Next i
        Application.ScreenUpdating = True
    
    
    End Sub
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2406 Win 11 Home 64 Bit
    Posts
    23,961

    Re: Macro to highlight cell based on value in below row

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks for the rep

+ 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] Highlight cell based on total quantity value based on repeated order numbers
    By PWilson0727 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-29-2014, 02:02 PM
  2. [SOLVED] Macro to highlight rows based on workday dates
    By Wedge120 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-25-2014, 03:39 PM
  3. macro to highlight rows based on column A
    By mugs62 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-28-2014, 07:20 AM
  4. Replies: 1
    Last Post: 01-20-2014, 03:52 AM
  5. Highlight a Row based on a cell
    By webstar in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 05-16-2007, 01:50 PM
  6. [SOLVED] Macro to highlight cells based on content
    By JimDerDog in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-01-2006, 11:55 AM

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