+ Reply to Thread
Results 1 to 12 of 12

How do I make Sheet Code available in all sheets

  1. #1
    Registered User
    Join Date
    10-16-2009
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    59

    How do I make Sheet Code available in all sheets

    I found sheet code on the forum that highlights the both the entire row and column when a cell is selected.

    This is great, but is there a way I can make this an add-in so it is easily available in all workbooks and sheets?

    Thanks!

    Code:
    Please Login or Register  to view this content.
    Last edited by antonf; 10-20-2009 at 10:42 AM.

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How do I make Sheet Code available in all sheets

    Hi,

    Use the

    Please Login or Register  to view this content.
    event. If it's just you that needs to use this then you could stick it in your Personal.xls workbook which is always resident in memory.

    Otherwise put it in a blank workbook and then save the workbook as a .xla add-in.

    HTH
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    10-16-2009
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    59

    Re: How do I make Sheet Code available in all sheets

    Thanks Richard

    I put the following code in Personal.xlsb, and it doesn't work...Sub
    Please Login or Register  to view this content.
    How should I do it, as a module? (Please note - I'm a noob when it gets to VBA!)
    Last edited by antonf; 10-19-2009 at 09:44 AM.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How do I make Sheet Code available in all sheets

    Hi,

    Change that to

    Please Login or Register  to view this content.

  5. #5
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: How do I make Sheet Code available in all sheets

    If you put it into the Personal macro workbook, it will only work for sheets in that workbook (not much use as it's hidden) unless you add an application-level event handler. I'd just use Chip Pearson's one from here personally...
    Remember what the dormouse said
    Feed your head

  6. #6
    Registered User
    Join Date
    10-16-2009
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    59

    Re: How do I make Sheet Code available in all sheets

    Thanks guys!!

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How do I make Sheet Code available in all sheets

    Sorry, just realised there's some confusion.

    Those two lines of code will only work when they are in the Workbook_SheetChange event of the activeworkbook, which is not what you're after since you want it to run in whatever is the active workbook

    You can run a macro in the Personal.xls workbook but to do that you need something to trigger the macro. i.e. a Button or Ctrl shortcut key.

    Go to the Personal.xls workbook in the Visual Basic Environment, Choose Insert Module unless there's one there already.

    Now add the following macro.

    Please Login or Register  to view this content.
    Now back in Excel choose Tools Macro Macros, select the Personal.xls workbook and click the 'HighlightRowColumn' macro.

    Then click the options button and enter a shortcut key, say 'h' for highlight.

    Now whenever you click Ctrl-h the row and column for the active cell in the active workbook will be highlighted.

    HTH

  8. #8
    Registered User
    Join Date
    10-16-2009
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    59

    Re: How do I make Sheet Code available in all sheets

    Was just about to post "Ouch, WTF am I doing wrong??" Losing the "undo" facility (Pearson Rowliner does that) is not nice...

    Follow up: How do I get rid of the previous "highlighting" when I run the macro in a different cell? In some case leaving it would be useful, in some case not... maybe two macros, one for times you want highlighting to remain, one if you don't?
    Last edited by antonf; 10-20-2009 at 09:53 AM.

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How do I make Sheet Code available in all sheets

    Hi,

    You could add an additional first line

    Please Login or Register  to view this content.
    This will first clear any highlights on the sheet before re-applying to the active cell.

    Create two macros one as before and one with this additional line and give them different short cut keys.

    HTH

  10. #10
    Registered User
    Join Date
    10-16-2009
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    59

    Re: How do I make Sheet Code available in all sheets

    This will remove all highlighting from cells I guess?

    Is it possible to only remove highlighting of a specific color? That way I can ensure that this macro uses a color not likely to be used as a "normal" fill color and the macro only removes that color? It will still be an issue because a previous cell color will be lost where it wasn't "blank", unless a table style is used?

  11. #11
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: How do I make Sheet Code available in all sheets

    Hi,

    You could experiment with code like the following at the top of the procedure.

    Please Login or Register  to view this content.
    This will clear rows that don't have a colour 8.
    You'll need to add a similar For..Next statement for the columns.

    HTH

  12. #12
    Registered User
    Join Date
    10-16-2009
    Location
    South Africa
    MS-Off Ver
    Office 365
    Posts
    59

    Re: How do I make Sheet Code available in all sheets

    Would it be possible when running the macro to highlight the row and column of the active cell to only highlight cells not yet colored/filled? That way it might be easy to remove the fill/color from all cells with color 8 and previous fill/color would remain unchanged?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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