Macro shortcuts are running macros in different open workbook


D

Don Wiss

I use the same macro shortcuts in different workbooks. Sometimes the
shortcuts run the same macro and act on the active worksheet. In those
cases if the shortcut runs the macro from a non-active workbook it will
still work. But one of the shortcuts has a different meaning in another
workbook, and if the shortcut decides to run the macro in that workbook
then it doesn't work.

When I use a shortcut how do I get it to run the macro in the active
workbook?

Don. www.donwiss.com (e-mail link at home page bottom).
 
Ad

Advertisements

G

GS

Don Wiss brought next idea :
I use the same macro shortcuts in different workbooks. Sometimes the
shortcuts run the same macro and act on the active worksheet. In those
cases if the shortcut runs the macro from a non-active workbook it will
still work. But one of the shortcuts has a different meaning in another
workbook, and if the shortcut decides to run the macro in that workbook
then it doesn't work.

When I use a shortcut how do I get it to run the macro in the active
workbook?

Don. www.donwiss.com (e-mail link at home page bottom).

Excel exhibits some bizarre behavior if macros are assigned the same
shortcuts or if 2 files with macros of the same name are open. The
behhavior varies depending on the order the files containing the macros
were opened. <IIRC>Normally the active shortcuts belong to the current
active file if it has macros, otherwise the last active file containing
macros.

So if 2 open files use the same shortcut to run a macro, the 1st file
that uses the shortcut will run its associated macro. It's usually
better to assign macros to a button or menuitem AND use this statement
at the top of each code module...

Option Private Module
Option Explicit

--
Garry

Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
D

Don Wiss

Don Wiss brought next idea :
Excel exhibits some bizarre behavior if macros are assigned the same
shortcuts or if 2 files with macros of the same name are open. The
behhavior varies depending on the order the files containing the macros
were opened. <IIRC>Normally the active shortcuts belong to the current
active file if it has macros, otherwise the last active file containing
macros.

So if 2 open files use the same shortcut to run a macro, the 1st file
that uses the shortcut will run its associated macro. It's usually
better to assign macros to a button or menuitem AND use this statement
at the top of each code module...

It has to be a keyboard macro, as it gets data from the ActiveCell.Row and
puts a string into the clipboard. There are three macros, each putting
different strings into the clipboard. The two spreadsheets are similar,
with ISBN numbers in column B.

I removed the shortcut in the other different workbook that was the same. I
thought about it and realized that it was no longer needed. So now it
doesn't matter which macro it runs, as they are identical and only read
column B of the ActiveCell.Row.
Option Private Module
Option Explicit

I am using Excel 97. I have always used Option Explicit. I have never used
Option Private Module.

Don. www.donwiss.com (e-mail link at home page bottom).
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top