ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro: Row transposing; event on open vs. shortcut key (https://www.excelbanter.com/excel-programming/309889-macro-row-transposing%3B-event-open-vs-shortcut-key.html)

Eric Schneider

Macro: Row transposing; event on open vs. shortcut key
 
I have a macro that formats data from one sheet and places it into
another. I assigned the a shortcut key. When I execute the shortcut
key everything works great.

However, when I put the same Sub in the OnOpen event of the Excel
workbook (to save users the trouble of having to execute this macro
manually everytime they open the file) it DOESN'T work. Rather
several of the columns are transposed and the row mapping from one
sheet to the other isn't exact either.

I'm at a loss. If the exact same code is being executed it should
either work by shortcut key AND OnOpen event...or else neither of them
should work.

Is this a known Excel bug of some type?

Any comments appreciated...
Thanks,
Eric

Tom Ogilvy

Macro: Row transposing; event on open vs. shortcut key
 
Depends on where you put it. If in a sheet module, then the code operates
differently there than if it were in a general module. This could be true
if you put it in the Thisworkbook module as well. Why not put the code in a
general module and have you onopen event just call it.

--
Regards,
Tom Ogilvy

"Eric Schneider" wrote in message
om...
I have a macro that formats data from one sheet and places it into
another. I assigned the a shortcut key. When I execute the shortcut
key everything works great.

However, when I put the same Sub in the OnOpen event of the Excel
workbook (to save users the trouble of having to execute this macro
manually everytime they open the file) it DOESN'T work. Rather
several of the columns are transposed and the row mapping from one
sheet to the other isn't exact either.

I'm at a loss. If the exact same code is being executed it should
either work by shortcut key AND OnOpen event...or else neither of them
should work.

Is this a known Excel bug of some type?

Any comments appreciated...
Thanks,
Eric




Eric Schneider

Macro: Row transposing; event on open vs. shortcut key
 
Tom - thanks for your response.

The code already exists in a standard module in the VBA project. The
Workbook_Open even simply calls the Sub that exists in this standard
module.

I've searched this newsgroup and found other posts that have labled
the Workbook_Open event "quirky" when calling macros so I'm getting
the impression this may be something I have to live with.

(The interesting thing is that I've tested the issue on 4 machines so
far all with the same OS and MSOffice/Excel versions and 3 of them are
fine...just 1 machine is showing the problem)

I will continue to search this newsgroup and if I find any more
definitive answer will post back here...


"Tom Ogilvy" wrote in message ...
Depends on where you put it. If in a sheet module, then the code operates
differently there than if it were in a general module. This could be true
if you put it in the Thisworkbook module as well. Why not put the code in a
general module and have you onopen event just call it.

--
Regards,
Tom Ogilvy

"Eric Schneider" wrote in message
om...
I have a macro that formats data from one sheet and places it into
another. I assigned the a shortcut key. When I execute the shortcut
key everything works great.

However, when I put the same Sub in the OnOpen event of the Excel
workbook (to save users the trouble of having to execute this macro
manually everytime they open the file) it DOESN'T work. Rather
several of the columns are transposed and the row mapping from one
sheet to the other isn't exact either.

I'm at a loss. If the exact same code is being executed it should
either work by shortcut key AND OnOpen event...or else neither of them
should work.

Is this a known Excel bug of some type?

Any comments appreciated...
Thanks,
Eric



All times are GMT +1. The time now is 08:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com