+ Reply to Thread
Results 1 to 21 of 21

A way to make a macro work on multiple sheets

  1. #1
    Registered User
    Join Date
    10-11-2012
    Location
    Bucharest
    MS-Off Ver
    2010
    Posts
    10

    Question A way to make a macro work on multiple sheets

    Good day,

    I have a bit of a problem. I searched everywhere for a solution but found nothing that could help me.

    I have this macro
    Please Login or Register  to view this content.
    And I have 34 sheets in which I want this macro to work, but in the workbook there are 36 sheets, the first 2 sheets should be excluded from this macro.

    Here is the workbook with all the sheets http://www.sendspace.com/file/8458nn
    The first sheet that should have the macro work on is sheet 103 Filipesti and the sheets to be excluded are Data and Centralizare Data.

    In sheet 103 Filipesti is how the sheets looks before running the macro and in sheet 104 Filipesti is how it looks after running the macro.

    Hope I've put all the information that was needed for someone to understand what I have and want to get.

    Anyone has an ideea to how can I make this work?

    Any and all help is appreciated
    Last edited by WraithGhost; 10-18-2012 at 07:40 AM. Reason: included sample file

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: A way to make a macro work on multiple sheets

    Use one of these in your code.
    Please Login or Register  to view this content.
    Last edited by AB33; 10-18-2012 at 09:32 AM.

  3. #3
    Valued Forum Contributor
    Join Date
    03-17-2012
    Location
    Warsaw, Poland
    MS-Off Ver
    2007/2010
    Posts
    555

    Re: A way to make a macro work on multiple sheets

    I can't access your file, but I'll try anyway:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    10-11-2012
    Location
    Bucharest
    MS-Off Ver
    2010
    Posts
    10

    Re: A way to make a macro work on multiple sheets

    I get a compile error

    "Next without For"

    This is the code that i used
    Please Login or Register  to view this content.

  5. #5
    Valued Forum Contributor
    Join Date
    03-17-2012
    Location
    Warsaw, Poland
    MS-Off Ver
    2007/2010
    Posts
    555

    Re: A way to make a macro work on multiple sheets

    end with goes before next I
    If you think that my answer was helpful, please click on the "Add to this user's Reputation" button.

  6. #6
    Registered User
    Join Date
    10-11-2012
    Location
    Bucharest
    MS-Off Ver
    2010
    Posts
    10

    Re: A way to make a macro work on multiple sheets

    Done that but it's not working.
    It works only if I have an active sheet...

  7. #7
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: A way to make a macro work on multiple sheets

    Also you can reduce your statements by half if you change this -

    For e.g. from
    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  8. #8
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: A way to make a macro work on multiple sheets

    Bishonen,
    Thank you for correcting my error!
    I think it would be easier for any one to see a mock workbook.

  9. #9
    Registered User
    Join Date
    10-11-2012
    Location
    Bucharest
    MS-Off Ver
    2010
    Posts
    10

    Re: A way to make a macro work on multiple sheets

    The sample workbook is here
    http://www.sendspace.com/file/8458nn
    or
    https://www.dropbox.com/s/n3158icauij4ext/sample.xlsm

    Hope one of this links work
    Last edited by WraithGhost; 10-18-2012 at 08:51 AM.

  10. #10
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: A way to make a macro work on multiple sheets

    WraithGhost,
    Sorry, it was my mistake.
    Could you please change this line
    Please Login or Register  to view this content.
    in to
    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    10-11-2012
    Location
    Bucharest
    MS-Off Ver
    2010
    Posts
    10

    Re: A way to make a macro work on multiple sheets

    Um...
    It still did not work.
    There are problems:
    1. It did not select the third sheet and start to run the macro from there.
    2. It did the same thing a bunch of times but on the same sheet, did nothing on the other sheets

    This was the latest code used that had the above mentioned effects.

    Please Login or Register  to view this content.
    It would be great if you could see this damn sample file
    https://www.dropbox.com/s/n3158icauij4ext/sample.xlsm

  12. #12
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: A way to make a macro work on multiple sheets

    Why not upload the sample file here directly?

  13. #13
    Registered User
    Join Date
    10-11-2012
    Location
    Bucharest
    MS-Off Ver
    2010
    Posts
    10

    Talking Re: A way to make a macro work on multiple sheets

    sample.xlsm

    Sorry, did not see the option before, looked for it but did not find it. Now I hope you can see the sample workbook

  14. #14
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: A way to make a macro work on multiple sheets

    Okay, you have Pivot Table, shapes and merged cells.
    Recently, I have learned that merging cells is a nightmare. They interfer with looping cells and I do not use them.

    I have tieded up your code and is now short, but it is not working. I am sure Bishonen and Arlu will add thier ten cents.
    Attached Files Attached Files
    Last edited by AB33; 10-18-2012 at 09:58 AM.

  15. #15
    Registered User
    Join Date
    10-11-2012
    Location
    Bucharest
    MS-Off Ver
    2010
    Posts
    10

    Re: A way to make a macro work on multiple sheets

    So you think that not merging would be better?

  16. #16
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: A way to make a macro work on multiple sheets

    Wraith,
    This site has been up and down since yesterday. I am unable to access it from time to time and even if I do, it is very slow.

  17. #17
    Registered User
    Join Date
    10-11-2012
    Location
    Bucharest
    MS-Off Ver
    2010
    Posts
    10

    Re: A way to make a macro work on multiple sheets

    I think there's something with your connection, I did not have any problems with the site...

  18. #18
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: A way to make a macro work on multiple sheets

    WraithGhost,

    Is this sorted?

  19. #19
    Registered User
    Join Date
    10-11-2012
    Location
    Bucharest
    MS-Off Ver
    2010
    Posts
    10

    Unhappy Re: A way to make a macro work on multiple sheets

    No.

    It did not work. Neither of the macros in the sample file given by AB33
    worked...


    In this file sample.xlsm you can see all the elements:
    1. the first 2 sheets that need to be excluded from the code
    2. the way the data looks in 103 Filipesti is exactly how it looks before the code that I've posted at first runs
    3. the way it looks after the code was runned is in 104 Filipesti.
    Last edited by WraithGhost; 10-21-2012 at 05:54 AM.

  20. #20
    Registered User
    Join Date
    10-21-2012
    Location
    qatar
    MS-Off Ver
    Excel 2010
    Posts
    1

    Re: A way to make a macro work on multiple sheets

    Try this:

    Please Login or Register  to view this content.

    Moderator Edit:

    Welcome to the forum, pippo12345.

    Please notice that [CODE] tags have been added to your post. The forum rules require them so please keep that in mind and add them yourself whenever showing code in any of your future posts. To see instructions for applying them, click on the Forum Rules button at the top of the page and read Rule #3.
    Thanks.
    Last edited by Cutter; 10-21-2012 at 12:36 PM. Reason: Added code tags

  21. #21
    Registered User
    Join Date
    10-11-2012
    Location
    Bucharest
    MS-Off Ver
    2010
    Posts
    10

    Re: A way to make a macro work on multiple sheets

    Thanks, pippo12345.

    That was exactly what I wanted.
    I guess that's the closest I can come to doing multiple sheets at the same time.

+ 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