+ Reply to Thread
Results 1 to 6 of 6

Excel 2007 - VBA code working perfectly on sheet 1 but not on the rest of the sheets

  1. #1
    Registered User
    Join Date
    03-22-2013
    Location
    West Sussex
    MS-Off Ver
    Office 365
    Posts
    81

    Excel 2007 - VBA code working perfectly on sheet 1 but not on the rest of the sheets

    I have created a simple work book to create delivery notes and then an end of week invoice.
    I have some simple macros running and on my first sheet the macro works perfectly but on the other sheets there is a slight problem with it and I cant work out why.
    If there is someone out there that I can send the document to, to see if you could shed some light I would greatly appreciate it.



    (Problem is from sheet 2 onwards and its the macro running from the 'SAVE' button).
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    12-29-2011
    Location
    Milwaukee, Wi
    MS-Off Ver
    Excel 2007
    Posts
    12

    Re: Excel 2007 - VBA code working perfectly on sheet 1 but not on the rest of the sheets

    i see a few things
    1. Each sheet points to the macro in sheet 1 so the assigned macro needs to be edited for each sheet
    2. since there seems to be no difference between the sheets codes, why not stick it all in mudule one and call it from there instead of from each sheet?

  3. #3
    Forum Contributor
    Join Date
    04-01-2009
    Location
    Irvine, CA
    MS-Off Ver
    Excel 2010
    Posts
    280

    Re: Excel 2007 - VBA code working perfectly on sheet 1 but not on the rest of the sheets

    The problem is all your save button macros are assigned to Sheet1.ConvertAllCellsToValues.
    If you assign them to the sheet they are on then the macro works.

  4. #4
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Excel 2007 - VBA code working perfectly on sheet 1 but not on the rest of the sheets

    Try changing ActiveSheet to Me in the code in the worksheet modules.

    Me is a reference to the worksheet the module belongs to.
    If posting code please use code tags, see here.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: Excel 2007 - VBA code working perfectly on sheet 1 but not on the rest of the sheets

    1) Remove all scripts from individual sheets. Just leave in the "activate" script on each sheet
    2) insert a regular code module (Insert > Module)
    3) Paste in this one set of macros. This will be used by all sheets:
    Please Login or Register  to view this content.
    4) Remove the buttons from all the sheets except Monday (trust me)
    5) Now connect the buttons on the Monday sheet back to the remaining visible macros in the list, there should just be the one version of each now
    6) Copy the 3 buttons to the other daily sheets
    Attached Files Attached Files
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  6. #6
    Registered User
    Join Date
    03-22-2013
    Location
    West Sussex
    MS-Off Ver
    Office 365
    Posts
    81

    Re: Excel 2007 - VBA code working perfectly on sheet 1 but not on the rest of the sheets

    Hi thanks all for the help problem solved :-)

+ 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