Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
R R is offline
external usenet poster
 
Posts: 6
Default Running a sub in a different workbook from a sub in this workbook?

I have a workbook called SAMMY with a worksheet called HOURS. I have
written a VBA sub that manipulates data on this worksheet. The VBA sub
is called hx. In the middle of hx, I need to call up a VBA MACRO from
the (sometimes closed and sometimes open) workbook called FRED, which
has a worksheet called ORDER. The MACRO is currently execured with a
button on FRED_ORDER that ties to the Macro:
FRED_ORDER.xls!order.order

So how do I invoke this Macro from the middle of the sub "hx" on
SAMMY?

ONE EXTRA IMPORTANT NOTE****:
The Macro FRED_ORDER.xls!order.order is completely dependant upon the
cursur being on cell A40 on the ORDER sheet in the FRED workbook. If
the active cell is not A40 on this sheet/workbook then this Macro
won't work (since it needs to "read" the A40 data to determine the
next action. So, when I invoke the macro from the SAMMY_HOURS_hx code
I need to also some how tell the vba code to get on cell a40 first,
before running the order.order, since the order.order macro ASSUMES
that one is already there when one runs it from FRED. Whew, that is
confusing! I hope it makes sense to one of you genuises!

Thnks in advance for the help. I am new to VBA and I am really
confused about how to do this!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 863
Default Running a sub in a different workbook from a sub in this workbook?

Just a comment on the part quoted below. That macro isn't written correctly,
then. It shouldn't refer to ActiveCell or Selection. If you need to work with
cell A40 specifically, the code should say, for example,

Range("A40").Offset(1,0)

not

ActiveCell.Offset(1,0)

If you can't correct that, then your code must open FRED_ORDER.xls, activate
the Order sheet and select cell A40. Only after doing that can you call the
macro in that workbook.

As for the command to run it, look at the Application.Run statement in Help.
It will show you the syntax.

On Fri, 29 Oct 2004 02:36:51 -0400, R wrote:

ONE EXTRA IMPORTANT NOTE****:
The Macro FRED_ORDER.xls!order.order is completely dependant upon the
cursur being on cell A40 on the ORDER sheet in the FRED workbook. If
the active cell is not A40 on this sheet/workbook then this Macro
won't work (since it needs to "read" the A40 data to determine the
next action.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running macro in another workbook Barb Reinhardt Excel Worksheet Functions 1 April 25th 07 08:30 PM
Workbook running VERY slow kippers Excel Discussion (Misc queries) 1 February 1st 07 03:27 PM
Help:Running a macro in one excel workbook from another workbook R Kapoor Setting up and Configuration of Excel 3 January 13th 06 05:11 AM
Running a macro in another workbook Blue Excel Programming 4 July 9th 04 07:38 PM
Running macros from another workbook [email protected] Excel Programming 4 November 21st 03 11:04 PM


All times are GMT +1. The time now is 06:32 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"