+ Reply to Thread
Results 1 to 7 of 7

How to apply macro to an entire workbook

  1. #1
    Registered User
    Join Date
    09-07-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    9

    Smile How to apply macro to an entire workbook

    Afternoon All

    I have an excel sheet with a macro that changes the colour of cells depending on their content. The problem I have is that the macro only runs for 1 of the sheets and not the others.

    Does anyone know how to go about making it run on all sheets?

    the code so far is:

    Please Login or Register  to view this content.

    I've also attached a screeshot of the code, Im using excel 2003, Most of the sheets are password protected as well if that makes a difference?

    regards

    D
    Attached Images Attached Images
    Last edited by Richard Buttrey; 09-08-2011 at 09:24 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 to apply macro to an entire workbook

    Hi,

    Please remember to wrap your code in code tags. Since you're new I'll change it for you this time.

    Put the code in the Workbook Sheet Change event.

    Regards
    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
    09-07-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: How to apply macro to an entire workbook

    Evening,

    thankyou for the quick reply

    I changed the first line from:
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    however it still behaves in exactly the same way,
    any other suggestions?

    regards

  4. #4
    Registered User
    Join Date
    09-07-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: How to apply macro to an entire workbook

    Afternoon All

    was my above change what I was meant to do or did I do something wrong?

    regards

  5. #5
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: How to apply macro to an entire workbook

    Hi David

    In addition to changing the line of code you need to MOVE the procedure FROM the Sheet Module TO the ThisWorkbook Module.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  6. #6
    Registered User
    Join Date
    09-07-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    9

    Re: How to apply macro to an entire workbook

    Morning all

    apologies for being a bit dim, Im still a beginner with macros

    How do I get access to the "thisworkbook" module?

    regards

  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 to apply macro to an entire workbook

    Hi

    In the Visual Basic Environment look in the 'Project - VBA Project' window on the top left.

    Find your particular workbook and if necessary expand the tree by clicking the small '+' sign. In this tree you'll find the 'This Workbook' object. Double click this. Then over on the right from the left hand drop down pick the Workbook Object, and in the right hand drop down select the SheetChange event.

    See attached picture

    Regards
    Attached Images Attached Images

+ 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