+ Reply to Thread
Results 1 to 9 of 9

Excel highlight current cell and everry 7th cell back

  1. #1
    Registered User
    Join Date
    05-08-2018
    Location
    Miami
    MS-Off Ver
    2007
    Posts
    5

    Excel highlight current cell and everry 7th cell back

    I am currently working with a file that contains dates in chronological order in column A and column B contains a dollar value. I would like to highlight the current cell in a color where I put the cursor and then highlight every 7th cell(week) back. For example, if I put my cursor on cell A11, I would like that cell to highlight yellow and then highlight every 7th cell back in the same color. I am looking at a weekly trends. I have the code, which highlights the entire row where I put the cursor but cannot get it to just highlight the cell and every 7th cell back. here is the code which highlights the entire row where the cursor is.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Cells.Count > 1 Then Exit Sub

    Application.ScreenUpdating = False
    ' Clear the color of all the cells
    Target.Parent.Cells.Interior.ColorIndex = 0
    With Target
    ' Highlight the entire row and column that contain the active cell
    .EntireRow.Interior.ColorIndex = 10

    End With
    Application.ScreenUpdating = True
    End Sub

  2. #2
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Excel highlight current cell and everry 7th cell back

    change this:

    Please Login or Register  to view this content.
    to this:

    Please Login or Register  to view this content.
    that will highlight the cell and not the row.

    working on last 7th item

  3. #3
    Registered User
    Join Date
    05-08-2018
    Location
    Miami
    MS-Off Ver
    2007
    Posts
    5

    Re: Excel highlight current cell and everry 7th cell back

    Thanks so much. Your code does exactly what I need for current cell. Thank you for working on highlighting also every 7th cell back. I will wait for your valuable answer.

  4. #4
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Excel highlight current cell and everry 7th cell back

    ok, i tested this and it works as you have described:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-08-2018
    Location
    Miami
    MS-Off Ver
    2007
    Posts
    5

    Re: Excel highlight current cell and everry 7th cell back

    Awesome. Works great. You know there is always a but...LOL. I currently have the row headers in ROW3 and would those not to be highlighted in the color ad remain as they are. Can you have the every 7th cell back stop at row 4 and not highlight beyond row 4?

  6. #6
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Excel highlight current cell and everry 7th cell back

    that is why we are here, always lots of buts, LOL

    i tidied up the code a bit, so here is what works:

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    05-08-2018
    Location
    Miami
    MS-Off Ver
    2007
    Posts
    5

    Re: Excel highlight current cell and everry 7th cell back

    Awesome. Works great. You know there is always a but...LOL. I currently have the row headers in ROW3 and would not like those not to be highlighted in the color and remain as they are. Can you have the code stop at row 3 and not highlight beyond row 3? Meaning not highlight rows 1-3.

  8. #8
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Excel highlight current cell and everry 7th cell back

    if this satisfies your needs, please mark the thread as solved and if your feeling generous, you can click on my "Add Reputation" link.

    my solution is meeting your needs in that it won't highlight A1:A3
    Last edited by dmcgov; 12-18-2018 at 01:34 PM.

  9. #9
    Valued Forum Contributor dmcgov's Avatar
    Join Date
    11-11-2015
    Location
    Florida, USA
    MS-Off Ver
    Office 365 Business
    Posts
    1,518

    Re: Excel highlight current cell and everry 7th cell back

    updated the solution

+ 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: 09-16-2017, 01:03 PM
  2. How to highlight the row and the line with contain the current cell?
    By woshichuanqilz in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 04-26-2017, 11:10 AM
  3. Way to highlight current active cell?
    By Carrfamily in forum Excel General
    Replies: 5
    Last Post: 05-08-2015, 07:07 PM
  4. Highlight cell if current month
    By her.rockstar in forum Excel General
    Replies: 4
    Last Post: 01-23-2013, 10:09 AM
  5. Replies: 8
    Last Post: 05-20-2012, 06:06 PM
  6. [SOLVED] highlight the current cell
    By D in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-02-2006, 07:25 AM
  7. [SOLVED] How do I highlight the current cell?
    By psilzle in forum Excel General
    Replies: 2
    Last Post: 08-25-2005, 03:05 PM

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