PC Review


Reply
Thread Tools Rate Thread

Call macro in other sheet

 
 
Tomas Stroem
Guest
Posts: n/a
 
      25th Jun 2009

I have a Master file containing a macro that opens a number of other
workbooks, collects data and the creates statistics from this retreived data,
work well. Now I need to create some statistics in on of the workbooks that I
open from my Master. In this Slave file I have the macro that I want to run,
but only when the Master is running. How can i call the macro in the Slave
worksheet from the code in the Master macro.

Greatful for all help!

--
Tomas S
 
Reply With Quote
 
 
 
 
Per Jessen
Guest
Posts: n/a
 
      25th Jun 2009

Hi Thomas

Look at this:

Application.Run ("SlaveFile.xls!Macro1")

Regards,
Per

"Tomas Stroem" <(E-Mail Removed)> skrev i meddelelsen
news:24E7770E-7439-4441-B529-(E-Mail Removed)...
>I have a Master file containing a macro that opens a number of other
> workbooks, collects data and the creates statistics from this retreived
> data,
> work well. Now I need to create some statistics in on of the workbooks
> that I
> open from my Master. In this Slave file I have the macro that I want to
> run,
> but only when the Master is running. How can i call the macro in the Slave
> worksheet from the code in the Master macro.
>
> Greatful for all help!
>
> --
> Tomas S


 
Reply With Quote
 
Tomas Stroem
Guest
Posts: n/a
 
      25th Jun 2009

Per,
Works partially. but nor quite.
The result now is this, Macro Error 1004: "Can not find the macro
"Statistics" in file..."

Macro name is correct as well as file name, any idea of more adaptions
needed??

--
Tomas S


"Per Jessen" wrote:

> Hi Thomas
>
> Look at this:
>
> Application.Run ("SlaveFile.xls!Macro1")
>
> Regards,
> Per
>
> "Tomas Stroem" <(E-Mail Removed)> skrev i meddelelsen
> news:24E7770E-7439-4441-B529-(E-Mail Removed)...
> >I have a Master file containing a macro that opens a number of other
> > workbooks, collects data and the creates statistics from this retreived
> > data,
> > work well. Now I need to create some statistics in on of the workbooks
> > that I
> > open from my Master. In this Slave file I have the macro that I want to
> > run,
> > but only when the Master is running. How can i call the macro in the Slave
> > worksheet from the code in the Master macro.
> >
> > Greatful for all help!
> >
> > --
> > Tomas S

>
>

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      25th Jun 2009

"Statistics" OR "Statistics.xls"

If this post helps click Yes
---------------
Jacob Skaria


"Tomas Stroem" wrote:

> Per,
> Works partially. but nor quite.
> The result now is this, Macro Error 1004: "Can not find the macro
> "Statistics" in file..."
>
> Macro name is correct as well as file name, any idea of more adaptions
> needed??
>
> --
> Tomas S
>
>
> "Per Jessen" wrote:
>
> > Hi Thomas
> >
> > Look at this:
> >
> > Application.Run ("SlaveFile.xls!Macro1")
> >
> > Regards,
> > Per
> >
> > "Tomas Stroem" <(E-Mail Removed)> skrev i meddelelsen
> > news:24E7770E-7439-4441-B529-(E-Mail Removed)...
> > >I have a Master file containing a macro that opens a number of other
> > > workbooks, collects data and the creates statistics from this retreived
> > > data,
> > > work well. Now I need to create some statistics in on of the workbooks
> > > that I
> > > open from my Master. In this Slave file I have the macro that I want to
> > > run,
> > > but only when the Master is running. How can i call the macro in the Slave
> > > worksheet from the code in the Master macro.
> > >
> > > Greatful for all help!
> > >
> > > --
> > > Tomas S

> >
> >

 
Reply With Quote
 
Tomas Stroem
Guest
Posts: n/a
 
      25th Jun 2009

Application.Run ("Supplier Total.xls!Statistics()")

--
Tomas S


"Jacob Skaria" wrote:

> "Statistics" OR "Statistics.xls"
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Tomas Stroem" wrote:
>
> > Per,
> > Works partially. but nor quite.
> > The result now is this, Macro Error 1004: "Can not find the macro
> > "Statistics" in file..."
> >
> > Macro name is correct as well as file name, any idea of more adaptions
> > needed??
> >
> > --
> > Tomas S
> >
> >
> > "Per Jessen" wrote:
> >
> > > Hi Thomas
> > >
> > > Look at this:
> > >
> > > Application.Run ("SlaveFile.xls!Macro1")
> > >
> > > Regards,
> > > Per
> > >
> > > "Tomas Stroem" <(E-Mail Removed)> skrev i meddelelsen
> > > news:24E7770E-7439-4441-B529-(E-Mail Removed)...
> > > >I have a Master file containing a macro that opens a number of other
> > > > workbooks, collects data and the creates statistics from this retreived
> > > > data,
> > > > work well. Now I need to create some statistics in on of the workbooks
> > > > that I
> > > > open from my Master. In this Slave file I have the macro that I want to
> > > > run,
> > > > but only when the Master is running. How can i call the macro in the Slave
> > > > worksheet from the code in the Master macro.
> > > >
> > > > Greatful for all help!
> > > >
> > > > --
> > > > Tomas S
> > >
> > >

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      25th Jun 2009

When you have a space in the workbook name add a single quote. Try the below.

Application.Run ("'Supplier Total.xls'!Statistics")

If this post helps click Yes
---------------
Jacob Skaria


"Tomas Stroem" wrote:

> Application.Run ("Supplier Total.xls!Statistics()")
>
> --
> Tomas S
>
>
> "Jacob Skaria" wrote:
>
> > "Statistics" OR "Statistics.xls"
> >
> > If this post helps click Yes
> > ---------------
> > Jacob Skaria
> >
> >
> > "Tomas Stroem" wrote:
> >
> > > Per,
> > > Works partially. but nor quite.
> > > The result now is this, Macro Error 1004: "Can not find the macro
> > > "Statistics" in file..."
> > >
> > > Macro name is correct as well as file name, any idea of more adaptions
> > > needed??
> > >
> > > --
> > > Tomas S
> > >
> > >
> > > "Per Jessen" wrote:
> > >
> > > > Hi Thomas
> > > >
> > > > Look at this:
> > > >
> > > > Application.Run ("SlaveFile.xls!Macro1")
> > > >
> > > > Regards,
> > > > Per
> > > >
> > > > "Tomas Stroem" <(E-Mail Removed)> skrev i meddelelsen
> > > > news:24E7770E-7439-4441-B529-(E-Mail Removed)...
> > > > >I have a Master file containing a macro that opens a number of other
> > > > > workbooks, collects data and the creates statistics from this retreived
> > > > > data,
> > > > > work well. Now I need to create some statistics in on of the workbooks
> > > > > that I
> > > > > open from my Master. In this Slave file I have the macro that I want to
> > > > > run,
> > > > > but only when the Master is running. How can i call the macro in the Slave
> > > > > worksheet from the code in the Master macro.
> > > > >
> > > > > Greatful for all help!
> > > > >
> > > > > --
> > > > > Tomas S
> > > >
> > > >

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      25th Jun 2009

This was saved from a post for a similar question. You'll have to change the
workbook name from personal.xls to the real name.

Dim pWkbk as workbook
set pwkbk = workbooks("Personal.xls")
application.run "'" & pwkb.name & "'!macronamehere", "parm1", "parm2"

or if you're returning a value from a function:

dim res as string 'or variant or long or ...
res = application.run("'" & pwkb.name & "'!macronamehere", "parm1", "parm2")

You could also create a reference to this personal.xls workbook and call it just
like it was built into excel.

Tools|references
(but give the personal.xls's project a nice unique name (not VBAProject).

ps.

If you're using a function living in personal.xls inside a cell:
=personal.xls!functionnamehere(a1,b1,c1)

or save the file as an addin (*.xla) and use it in the cell like it's built into
excel:
=functionnamehere(a1,b1,c1)

Tomas Stroem wrote:
>
> I have a Master file containing a macro that opens a number of other
> workbooks, collects data and the creates statistics from this retreived data,
> work well. Now I need to create some statistics in on of the workbooks that I
> open from my Master. In this Slave file I have the macro that I want to run,
> but only when the Master is running. How can i call the macro in the Slave
> worksheet from the code in the Master macro.
>
> Greatful for all help!
>
> --
> Tomas S


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Call A Subroutine on a Sheet Sometimes stops? RJQMAN Microsoft Excel Programming 1 12th Jul 2010 12:11 AM
How do I change a macro to call a sheet from another workbook Nic@Rolls-Royce Microsoft Excel Programming 2 9th Feb 2004 08:47 AM
Re: How do I change a macro to call a sheet from another workbook Rob van Gelder Microsoft Excel Programming 0 9th Feb 2004 08:30 AM
Re: Call an Excel Macro when a Sheet is selected pfsardella@yahoo.com.nospam Microsoft Excel Programming 0 16th Oct 2003 07:01 PM
Why wouldn't calling the Activate sub for a sheet automatically call that sheet's Worksheet_Activate() sub? Scott Lyon Microsoft Excel Programming 3 19th Aug 2003 03:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:04 PM.