+ Reply to Thread
Results 1 to 12 of 12

running multiple macros

  1. #1
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    140

    running multiple macros

    Hi

    I have a master template of a spreadsheet, within here there are tabs monday to sunday and each has their own macro on it. i created a macro to run these macros one after another but the problem arises when i put some data into the spreadsheet, save it with another name and try to run the new macro. as the macro to run macros name is the name of the template then it will not run. is there a way around this?

  2. #2
    Valued Forum Contributor
    Join Date
    05-08-2012
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2003, 2010
    Posts
    811

    Re: running multiple macros

    It appears your macro has the tab names "hard coded" in. You need change the macro to more flexible and not use hard coded addresses
    Click on star (*) below if this helps

  3. #3
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: running multiple macros

    and how do i do this?

  4. #4
    Valued Forum Contributor
    Join Date
    05-08-2012
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2003, 2010
    Posts
    811

    Re: running multiple macros

    Goto into Visual Basic and see if it is hard coded.
    Others can help you with the Visual Basic code but the new reference would be like
    Active.Sheet rather than an absolute address

  5. #5
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: running multiple macros

    I'm fairly new to macro's and visual basic so i'm not too sure what you mean to be honest. you said in your first reply about the tab names being hard coded. its not the tab names that are the problem, its the name of the document im working on

  6. #6
    Valued Forum Contributor
    Join Date
    05-08-2012
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2003, 2010
    Posts
    811

    Re: running multiple macros

    Perhaps you could attach an example with a better explanation of the problem.

  7. #7
    Valued Forum Contributor
    Join Date
    05-08-2012
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2003, 2010
    Posts
    811

    Re: running multiple macros

    Post an Example spreadsheet

  8. #8
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: running multiple macros

    This is the macro which i am running and it is saved on a master copy:-


    Sub mondaytofriday()
    '
    ' mondaytofriday Macro
    '

    '
    Application.Run _
    "'Timesheet with macros master - USE THIS ONE.xlsm'!MONDAY.HideXRows"
    Sheets("TUESDAY").Select
    Application.Run _
    "'Timesheet with macros master - USE THIS ONE.xlsm'!TUESDAY.HideXRows"
    Sheets("WEDNESDAY").Select
    Application.Run _
    "'Timesheet with macros master - USE THIS ONE.xlsm'!WEDNESDAY.HideXRows"
    Sheets("THURSDAY").Select
    Application.Run _
    "'Timesheet with macros master - USE THIS ONE.xlsm'!THURSDAY.HideXRows"
    Sheets("FRIDAY").Select
    Application.Run _
    "'Timesheet with macros master - USE THIS ONE.xlsm'!FRIDAY.HideXRows"


    End Sub


    As you can see the document is called "Timesheet with macros master - USE THIS ONE.xlsm" When i input data into this document i resave it as something like "10 WK COMM 2nd JULY.xlsm" thus causing a problem with the macro as it doesn't know the file name has been changed

    Hope this helps

  9. #9
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: running multiple macros

    the spreadsheet is too big to post and i can't remove any tabs as that will mess up the macro.

  10. #10
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: running multiple macros

    can you help me or not?

  11. #11
    Valued Forum Contributor
    Join Date
    05-08-2012
    Location
    Georgia, USA
    MS-Off Ver
    Excel 2003, 2010
    Posts
    811

    Re: running multiple macros

    You could open the macro module(s) and search and replace
    "Timesheet with macros master - USE THIS ONE.xlsm"
    with
    "10 WK COMM 2nd JULY.xlsm"

  12. #12
    Forum Contributor
    Join Date
    04-24-2012
    Location
    Manchester
    MS-Off Ver
    Excel 2007
    Posts
    140

    Re: running multiple macros

    Yeah i found this workaround but each week i will have to go into multiple macros in multiple workbooks, i just wondered if there was a way where instead of the filename being there is was something like ThisWorkbook. thanks for your reply

+ 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