+ Reply to Thread
Results 1 to 15 of 15

How to call a macro in another sheet

  1. #1
    Registered User
    Join Date
    02-17-2017
    Location
    Norway
    MS-Off Ver
    2016
    Posts
    10

    How to call a macro in another sheet

    I have three sheets (sheet1, sheet2 and sheet3). I have registered a macro on sheet 1 that adds a column and converts seconds to minutes. In sheet 2 I have created a macro that filters data in a table and should copy data to sheet3. I want to create a macro that calls theese macros to execute and do what they were intended to do by creating a figure in sheet 3 and relate it to this "master macro" . How can I do that?

    I have tried, without any success.

    Please Login or Register  to view this content.
    Last edited by jeffreybrown; 02-20-2017 at 11:08 AM. Reason: Please use code tags!

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: How to call a macro in another sheet

    Your code looks fine for a Call.

    Have you tried to step thru the code to see what is happening?
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    02-17-2017
    Location
    Norway
    MS-Off Ver
    2016
    Posts
    10

    Re: How to call a macro in another sheet

    Yes, The Macros runs on sheet 3, Nothing happens in sheet 1 or 2

  4. #4
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: How to call a macro in another sheet

    Can you provide the workbook with the code!

  5. #5
    Registered User
    Join Date
    02-17-2017
    Location
    Norway
    MS-Off Ver
    2016
    Posts
    10

    Re: How to call a macro in another sheet

    This examplefile should illustrate my problem.
    Attached Files Attached Files

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

    Re: How to call a macro in another sheet

    As they are written the code in the subs will run against the currently active sheet.

    What is the first sub meant to do?

    Which sheets do you actually want the code to run against?
    If posting code please use code tags, see here.

  7. #7
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: How to call a macro in another sheet

    I don't quite understand the Call copy_text_to_sheet3 and what you are tying to accomplish.

    As for the Convert, try...

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    02-17-2017
    Location
    Norway
    MS-Off Ver
    2016
    Posts
    10

    Re: How to call a macro in another sheet

    Quote Originally Posted by jeffreybrown View Post
    I don't quite understand the Call copy_text_to_sheet3 and what you are tying to accomplish.
    My problem is that I can`t publish the sheet I am working on. It contains info I don`t want to be public. Since I have severeal sheets (many more than 3 acutally in the original document), and macros running on the different pages, I want to find a methode beeing able to run all the macros with just one push on a button without having to step into each and one sheet to run one macro at a time.

  9. #9
    Registered User
    Join Date
    02-17-2017
    Location
    Norway
    MS-Off Ver
    2016
    Posts
    10

    Re: How to call a macro in another sheet

    What does this line do?

    Please Login or Register  to view this content.
    Last edited by jeffreybrown; 02-20-2017 at 02:22 PM. Reason: Code tags please!

  10. #10
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: How to call a macro in another sheet

    Quote Originally Posted by torgn View Post
    I want to find a method being able to run all the macros with just one push on a button without having to step into each and one sheet to run one macro at a time.
    And that you can do! You just need to qualify the sheets so the macro knows what sheets to get the data from.

  11. #11
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: How to call a macro in another sheet

    It copies the formula to:

    Please Login or Register  to view this content.
    Does this small example help!
    Attached Files Attached Files
    Last edited by jeffreybrown; 02-20-2017 at 02:14 PM.

  12. #12
    Registered User
    Join Date
    02-17-2017
    Location
    Norway
    MS-Off Ver
    2016
    Posts
    10

    Re: How to call a macro in another sheet

    Quote Originally Posted by jeffreybrown View Post
    I don't quite understand the Call copy_text_to_sheet3 and what you are tying to accomplish.

    As for the Convert, try...

    Please Login or Register  to view this content.
    This seems to fit my purpose, but how do I add a new column to the c column?

  13. #13
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,316

    Re: How to call a macro in another sheet

    Quote Originally Posted by torgn View Post
    This seems to fit my purpose, but how do I add a new column to the c column?
    I'm not exactly sure what you mean by add a new column! Can you give some contest please?

  14. #14
    Registered User
    Join Date
    02-17-2017
    Location
    Norway
    MS-Off Ver
    2016
    Posts
    10

    Re: How to call a macro in another sheet

    What I was trying to say

    Have The following columns:
    Network Address, Remote Site, Duration (sec),Duration,Call Direction,Call Type

    I have created a macro with help from you for converting values and send the output to next column.

    Please Login or Register  to view this content.
    Before I can run this code/Macro I have to create an empty column next to Duration (sec) to place the output from the Convert_hours_to_minutes Macro. The clue is stil that I don`t wan`t to switch between sheets everytime I want to run a macro, but just one button to push that execute all (or most of) my macros on different sheets.

  15. #15
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,010

    Re: How to call a macro in another sheet

    A..... It appears you want a new colum after Column D. This macro creates a new column to the left of Column E
    which accomplishes your goal.

    Please Login or Register  to view this content.
    B..... Not certain where you want the new macro above that creates a new blank column.


    C..... I changed the macro for copy / paste from Ark2. It works now.

    D..... Your macro (below) functions well as is. Simply place the calls to the various macros in the order you want them executed.

    As it is right now, the macros are executing in this order:

    #1 copy_text_to-sheet3
    #2 Convert_hours_to-minutes.

    If this order is ok, then simply add the next macro call below - or - rearrange the order.

    E.....
    Please Login or Register  to view this content.
    Attached Files Attached Files

+ 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. hw we call a private macro in other sheet from module1
    By santosh226001 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-17-2014, 01:57 PM
  2. [SOLVED] How to call a click button which is on another spread sheet in your MACRO
    By kbriaz in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 08-05-2013, 05:35 AM
  3. How to call a sheet-specific macro
    By 4am in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-23-2013, 01:52 PM
  4. Call sub for another sheet + when sheets name is string in sheet
    By Marianus in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-30-2013, 04:28 PM
  5. [SOLVED] Macro to call data from a specified file in the sheet
    By tpayne89 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-20-2012, 09:28 AM
  6. Call macro (Sheet 1) from any change in sheet 2
    By mark02 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-12-2012, 10:29 PM
  7. Set cell focus based on list, call macro from sheet
    By itsunclebill in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-15-2009, 08:42 PM
  8. Macro to call sheet number instead of name
    By Alexis2891 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 01-13-2007, 07:57 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