+ Reply to Thread
Results 1 to 16 of 16

Highlighting selected row/column

  1. #1
    Forum Contributor
    Join Date
    11-23-2015
    Location
    Yada, Wales
    MS-Off Ver
    Office 2013
    Posts
    176

    Highlighting selected row/column

    Searching for a highlighter that does the following:

    * limit selection, which means not selecting below or to the right of the selected cell.
    * be transparent, not erasing any cell colors
    * change automatically when selection changes

    Highlight-Active-Cell-Code-310x165.png


    Found a highlighter on Microsoft homepage.
    When running code below in a worksheet (code for highlighting selected row and column), it firsts asks me to choose a name for another macro.
    But I can only choose names for other macros already created, not create a new name for this macro. I want this macro to activate by itself when I open the document.


    Please Login or Register  to view this content.
    Last edited by jokris; 03-28-2016 at 12:34 AM.

  2. #2
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Highlighting selected row/column

    Place the following code in ThisWorkbook Module, not in standard module or sheet module. To do that, double click ThisWorkbook from the project explorer on VBA editor and paste the following code into opened code window.

    Please Login or Register  to view this content.
    Regards
    sktneer


    Treat people the way you want to be treated. Talk to people the way you want to be talked to.
    Respect is earned NOT given.

  3. #3
    Forum Contributor
    Join Date
    11-23-2015
    Location
    Yada, Wales
    MS-Off Ver
    Office 2013
    Posts
    176

    Re: Highlighting selected row/column

    It worked, but when I select another cell it doesn't follow along.

    I would like a highlighter to:

    * limit selection, which means not selecting below or to the right of the selected cell.
    * be transparent, not erasing any cell colors
    * change automatically when selection changes

  4. #4
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,692

    Re: Highlighting selected row/column

    If you have that code in your sheet module, it works as it should for that particular sheet.

  5. #5
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Highlighting selected row/column

    That is what your code for Worksheet_SelectionChange does. It is triggered automatically with the selection. So why would you need that code with Workbook_Open event?

  6. #6
    Forum Contributor
    Join Date
    11-23-2015
    Location
    Yada, Wales
    MS-Off Ver
    Office 2013
    Posts
    176

    Re: Highlighting selected row/column

    The problem is that when I use Worksheet_Selection is that it doesn't activate automatically, and when I press F5 it asks me to select an already existing macro name.

    Tried to insert code both as module, in sheet and in workbook.

    Would like something like this, with transparent yellow.

    Highlight-Active-Cell-Code-310x165.png
    Last edited by jokris; 03-28-2016 at 12:33 AM.

  7. #7
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Highlighting selected row/column

    Where have you placed that code? The code for selection change event should be placed on the Sheet module. Right click the Sheet Tab --> View code and paste the code from your post#1 into the opened code window.

  8. #8
    Forum Contributor
    Join Date
    11-23-2015
    Location
    Yada, Wales
    MS-Off Ver
    Office 2013
    Posts
    176

    Re: Highlighting selected row/column

    I made a small movie showing how I did.

    http://youtu.be/Pzvw20ei2sA?hd=1

  9. #9
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Highlighting selected row/column

    Can you upload the workbook in question?

    In the attached, I have placed your code on Sheet1 Module. Let me know if that works for you.
    Attached Files Attached Files

  10. #10
    Forum Contributor
    Join Date
    11-23-2015
    Location
    Yada, Wales
    MS-Off Ver
    Office 2013
    Posts
    176

    Re: Highlighting selected row/column

    It was just an empty workbook.

    Tried your file too, same problem.

  11. #11
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Highlighting selected row/column

    Well that is something strange.
    1) Did you enable the macros when you opened the downloaded file?
    2) Can you run any code from a standard module?

  12. #12
    Forum Contributor
    Join Date
    11-23-2015
    Location
    Yada, Wales
    MS-Off Ver
    Office 2013
    Posts
    176

    Re: Highlighting selected row/column

    Yes I activate macros when asked for. Other macro codes can be run as usual.

  13. #13
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Highlighting selected row/column

    Open VBA editor by pressing Alt+F11.
    Now open Immediate Window by pressing Ctrl+G
    In the immediate window, type ?Application.EnableEvents and hit enter. What do you get True or False?

  14. #14
    Forum Contributor
    Join Date
    11-23-2015
    Location
    Yada, Wales
    MS-Off Ver
    Office 2013
    Posts
    176

    Re: Highlighting selected row/column

    I received False when trying.

  15. #15
    Forum Guru sktneer's Avatar
    Join Date
    04-30-2011
    Location
    Kanpur, India
    MS-Off Ver
    Office 365
    Posts
    9,655

    Re: Highlighting selected row/column

    That's why your code was not running.
    Now in the Immediate Window, type Application.EnableEvents=True and hit enter and see if the selection change event code works for you.

  16. #16
    Forum Contributor
    Join Date
    11-23-2015
    Location
    Yada, Wales
    MS-Off Ver
    Office 2013
    Posts
    176

    Re: Highlighting selected row/column

    Now it's working

    But the code wipes out cell colors, so probably will end up not using it at all.

+ 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] Highlighting row and column of selected cell - revisited
    By adamsc57 in forum Excel General
    Replies: 5
    Last Post: 07-15-2015, 05:32 PM
  2. [SOLVED] Listbox highlighting selected item in worksheet
    By Shellybelly in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-16-2015, 09:10 PM
  3. Highlighting selected cells in column B and C
    By chrisjack in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 11-05-2012, 04:36 PM
  4. Hide Selected Shape Highlighting
    By Brown207 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-28-2011, 02:43 PM
  5. Selected Cell Highlighting
    By boylejob in forum Excel General
    Replies: 3
    Last Post: 08-05-2010, 04:04 PM
  6. Highlighting a Row when a cell is selected
    By julvaz in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-18-2007, 02:56 AM
  7. Highlighting the selected row or column
    By Lewis Clark in forum Excel General
    Replies: 4
    Last Post: 05-02-2005, 09:06 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