+ Reply to Thread
Results 1 to 5 of 5

VBA that highlights a cell when selected (returning existing fill - if applicable)

  1. #1
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    VBA that highlights a cell when selected (returning existing fill - if applicable)

    This code was just posted by mike at this thread;

    https://www.excelforum.com/excel-pro...-selected.html
    Please Login or Register  to view this content.
    I think this is great.

    Is there a way to modify the code so that if the selected cell is already filled with any colour then that colour is stored and when any other cell is selected the original cell fill colour is returned to the first cell?

    ie. Cell 1 is filled RED (or any other colour).
    Cell 1 is selected and goes YELLOW
    Cell 2 is selected and Cell 1 returns to RED (or any other colour) and Cell 2 goes YELLOW.
    Last edited by kersplash; 08-02-2018 at 04:27 AM.

  2. #2
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: VBA that highlights a cell when selected (returning existing fill - if applicable)

    Try this:-
    NB:- Paste code at top of worksheet module.
    Please Login or Register  to view this content.
    Regards Mick
    Last edited by MickG; 08-02-2018 at 06:32 AM.

  3. #3
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: VBA that highlights a cell when selected (returning existing fill - if applicable)

    Thanks Mick,

    Are you able to show me how I may incorporate your code into what I already have?

    I would like this to be in my Personal.xlsb file.

  4. #4
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,607

    Re: VBA that highlights a cell when selected (returning existing fill - if applicable)

    kersplash

    What do you want for something like...

    Cell was originally colored Red and now Yellow when selected.
    Close the workbook.
    Select other cell and what color should be in the cell before that was originally Red?
    If you want it Red, you need to keep the information in somewhere like hidden sheet I guess.

  5. #5
    Forum Expert kersplash's Avatar
    Join Date
    11-22-2016
    Location
    Perth
    MS-Off Ver
    Home 2016 (Windows 10)/Work 2013 Pro Plus (Windows 10)
    Posts
    2,012

    Re: VBA that highlights a cell when selected (returning existing fill - if applicable)

    Let me explain.

    I work with 2 screens referring to my spreadsheet for information.

    If I select cells normally (without this VBA) - I get a greyish fill that shows within the selected cell.

    I go to my second screen to work on a document and the greyish fill is no longer present in my spreadsheet as the focus is no longer on the spreadsheet.

    When I'm working on my document and referring to my spreadsheet it would be nice for a highlighting to appear which is what my initial VBA in personal.xlsb does fine.

    Now I have spreadsheets that has different cell highlighting throughout, if I use this VBA solution, when I select an already highlighted cell, it changes to YELLOW.

    When I deslect the cell it removes all the highlighting and doesn't return the original colour.

    Also I can no longer highlight any cells with any colour as this VBA removes the highlighting each time.

+ 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. Listbox selected item un-highlights when moving to another pat of the form
    By Happytab in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-15-2018, 04:24 AM
  2. [SOLVED] Master tab serial number list parsed out to applicable cells in applicable worksheets
    By kiwimtnbkr in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-27-2017, 10:57 AM
  3. Replies: 0
    Last Post: 05-16-2013, 04:39 PM
  4. How to change existing code that highlights duplicates?
    By simonwilliams in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-22-2009, 10:47 AM
  5. Replies: 6
    Last Post: 02-22-2007, 01:07 AM
  6. Replies: 2
    Last Post: 02-15-2006, 05:45 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