+ Reply to Thread
Results 1 to 6 of 6

Make the same VBA code work for all sheets of the Workbook.

  1. #1
    Registered User
    Join Date
    08-06-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    35

    Smile Make the same VBA code work for all sheets of the Workbook.

    Hello,

    I have a code that's works on one the sheet1, and I want that same code (vba) to works the same way for all sheets, otherwise I have to copy separately the code for each sheet (sheet2, sheet3... sheet12 and so on) and that requerys a lot of the same code on the Worksheets and time, is that possible?. I think everything is possible to do in VBA for the gurus experts like that the have in Excel F?rum.

    The sheet have a six columns, one with automatic calendar that triggers in a cell in the column A, and another five columns for values, sums and the total.

    Budget.JPG

    Any help will be greatly appreciated.

    Regard's
    FS

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Make the same VBA code work for all sheets of the Workbook.

    Move the code to the ThisWorkbook module in the Workbook_SheetChange or Workbook_SheetSelectionChange event as appropriate.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Registered User
    Join Date
    08-06-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Make the same VBA code work for all sheets of the Workbook.

    Hello,

    Thanks for the suggestion, but can you please give me an example?

    Best regards.
    FS

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Make the same VBA code work for all sheets of the Workbook.

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    08-06-2010
    Location
    Portugal
    MS-Off Ver
    Excel 2007
    Posts
    35

    Re: Make the same VBA code work for all sheets of the Workbook.

    Hello again,

    I'am sorry for the inconvenience.
    I made your suggestion, and the "Calendar1" give the error "Run time Error 424: Object required", can you help me to solve that, I would be very grateful.

    Best regards
    FS
    Attached Files Attached Files

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Make the same VBA code work for all sheets of the Workbook.

    I don't have the calendar control on my system (and it was deprecated in Excel 2007). But it's an ActiveX control, which means that when used on a worksheet (as opposed to on a userform), you're stuck having the event handlers in the worksheet code module.

    There are third-party versions that use small userforms that look like the calendar control that may work for you; their events are processed in the form's code module, and so only need to appear once. Google excel alternative calendar control. I have not used any of them, so can't make a recommendation.

+ 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: 1
    Last Post: 08-14-2013, 12:01 PM
  2. {DELETE}Make a single sheet macro work for all sheets in workbook
    By TwistedGhost in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-05-2013, 04:29 PM
  3. VBA Code to work on multiple sheets in a workbook
    By Ironman in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-12-2012, 06:35 PM
  4. Make this macro work for all sheets in workbook
    By jonno in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-01-2010, 07:16 AM
  5. Can this code work with multiple sheets in one workbook
    By clbutler2008 in forum Excel General
    Replies: 1
    Last Post: 07-11-2008, 07:50 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