+ Reply to Thread
Results 1 to 6 of 6

Macro will not run in all worksheets

  1. #1
    Registered User
    Join Date
    10-19-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    3

    Macro will not run in all worksheets

    Hello gentlemen:

    First time poster. I want to thank everybody in advance for your help.

    I recorded a macro to sort a selection. The macro works fine in the worksheet where I created it but it won't work in other worksheets in the same workbook. I think I see the problem but I can't figure out how to fix it. The code spells the name of the worksheet where it was created. I tried different things but nothing works. The code currently runs on worksheet "TDL". I want it to run on "KPI" and "MSC". Here is the code (I hope I'm doing this correctly):

    Please Login or Register  to view this content.

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: Macro will not run in all worksheets

    Maybe try, untested:

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    10-19-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    3

    Re: Macro will not run in all worksheets

    Thank you TMS. Unfortunatelly it did not work. Thanks for trying though.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: Macro will not run in all worksheets

    it did not work
    is not very specific or helpful.

    What did it not do that it should? Or what did it do that it shouldn't? Was there an error? If so, what was it? Did it do nothing? Does it work on any sheets? The original sheet but not the others? Is the layout of the other sheets the same?

    This line:
    Please Login or Register  to view this content.
    will depend on the cell that is selected on the sheet when you run the macro. Is the same cell selected on every sheet?

    Regards, TMS

  5. #5
    Registered User
    Join Date
    10-19-2014
    Location
    USA
    MS-Off Ver
    2010
    Posts
    3

    Re: Macro will not run in all worksheets

    Good point TMS. I apologize for that. When I use the code you provided the macro stops working. No it will not sort even in the original worksheet (TDL). It won't work in any of the others either.

    Also, i just figured out that my original macro was running on the original worksheet where it was created (TDL) every time. So for example, I would go to worksheet "KPI" make a selection and run the macro, it would sort the range I selected on "KPI" but in "TDL".

    In regards to selection (TopLeft...) I created so that it would run in whatever I select each time. That part works fine.

    Thank you,

    Gonzalo

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,428

    Re: Macro will not run in all worksheets

    Suggest you provide a sample workbook with some typical data.

    You need to indicate how you would hope to use the macro on each sheet. For example, what column would be selected on sheet TDL, what column would be selected on sheet KPI.

    regards, TMS

+ 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. Macro that reads a list of worksheets, selects the sheets and performs a macro
    By JohnPellerin in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-05-2013, 05:04 AM
  2. Replies: 8
    Last Post: 04-21-2013, 01:58 AM
  3. Replies: 0
    Last Post: 03-28-2013, 10:25 AM
  4. VBA / Macro for creating new worksheets and new columns from existing worksheets
    By webby2006 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-25-2006, 10:38 AM
  5. Replies: 3
    Last Post: 03-20-2006, 01:25 AM

Tags for this Thread

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