Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Macro works from RUN but not from shortcut

I have a macro which opens an workbook and then transfers
date from the just opened book into the book which has the
macro. The macro will then close the external workbook.

This is using Excel 2002 with Windoes ME.

This macro runs fine when single stepping through it and
it works fine when selecting it and then hitting "RUN"
from the Tools-Macro-Macros menu but when using a shortcut
key, the macro will start to run normally but then it will
not execute the statements directly above the section with
the close in it. I tried a couple of different shortcut
key combos just in case it was a conflict in the shortcuts
but no change.


I have tried running the macro by "Call"ing it from
another macro and I have tried inserting a for-next loop
in a couple of places simply to use some time in case it
is not getting a chance to comple the preceeding steps but
still it will not operate correctly when using the
shortcut.

The code which opens the file and some of the following
code is:
Windows("Even-WeeklyMasters.xls").Activate
Sheets("Master").Select
varYear = InputBox("Enter full name, NOT
including .xls, of the file being used to create the
updated master sheets.")
varYear2 = "C:\ECTL\" & varYear
varyear1 = varYear & ".xls"

Workbooks.Open (varYear2)
Sheets("WeeklySheetsOdd").Select
Range("shootdates").Select
Selection.Copy
Windows("Even-WeeklyMasters.xls").Activate
Range("bg1").Activate
Selection.PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

'Application.ScreenUpdating = False
'Sheets("Master").Select
Range("A1").Select
Windows("Even-WeeklyMasters.xls").Activate
Range("master_clear").ClearContents
Range("master_clear").ClearComments

Range("master_clear").Interior.ColorIndex = xlNone
'Selection.
Range("a1").Activate


Windows(varyear1).Activate
Range("names_al_1").Copy
Windows("Even-WeeklyMasters.xls").Activate
Range("m_al_names_1").Activate
Selection.PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

The code used which seems not to execute when run from the
shortcut, but which does run fine when using the Run
button, (code which does not run marked with *) is:

Windows(varyear1).Activate
Range("names_sp_1").Copy
Windows("even-weeklymasters.xls").Activate
Range("m_sp_names_1").Activate
Selection.PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

* Windows("Even-WeeklyMasters.xls").Activate
Sheets("Master").Select

* MsgBox ("The workbook being used to supply names, ") &
varyear1 & (" will now be closed.")

Workbooks(varyear1).Close SaveChanges:=False


The Msgbox line and the line above it will NOT execute
when run from the shortcut but does appear when the macro
is strated from the Run button or when single stepping.

HELP!!!! Why will it not run properly from the
Shortcut????
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Macro works from RUN but not from shortcut

Your shortcut key has includes the shift key?

If yes, use a different shortcut key (w/o the shift key).

(When you open a file while holding the shift key, you disable the
auto_open/workbook_open macros. Excel gets confused and thinks it should stop
running macros when you do this with the shortcut key, too.)

Joe Pyrdek wrote:

I have a macro which opens an workbook and then transfers
date from the just opened book into the book which has the
macro. The macro will then close the external workbook.

This is using Excel 2002 with Windoes ME.

This macro runs fine when single stepping through it and
it works fine when selecting it and then hitting "RUN"
from the Tools-Macro-Macros menu but when using a shortcut
key, the macro will start to run normally but then it will
not execute the statements directly above the section with
the close in it. I tried a couple of different shortcut
key combos just in case it was a conflict in the shortcuts
but no change.


I have tried running the macro by "Call"ing it from
another macro and I have tried inserting a for-next loop
in a couple of places simply to use some time in case it
is not getting a chance to comple the preceeding steps but
still it will not operate correctly when using the
shortcut.

The code which opens the file and some of the following
code is:
Windows("Even-WeeklyMasters.xls").Activate
Sheets("Master").Select
varYear = InputBox("Enter full name, NOT
including .xls, of the file being used to create the
updated master sheets.")
varYear2 = "C:\ECTL\" & varYear
varyear1 = varYear & ".xls"

Workbooks.Open (varYear2)
Sheets("WeeklySheetsOdd").Select
Range("shootdates").Select
Selection.Copy
Windows("Even-WeeklyMasters.xls").Activate
Range("bg1").Activate
Selection.PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

'Application.ScreenUpdating = False
'Sheets("Master").Select
Range("A1").Select
Windows("Even-WeeklyMasters.xls").Activate
Range("master_clear").ClearContents
Range("master_clear").ClearComments

Range("master_clear").Interior.ColorIndex = xlNone
'Selection.
Range("a1").Activate


Windows(varyear1).Activate
Range("names_al_1").Copy
Windows("Even-WeeklyMasters.xls").Activate
Range("m_al_names_1").Activate
Selection.PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

The code used which seems not to execute when run from the
shortcut, but which does run fine when using the Run
button, (code which does not run marked with *) is:

Windows(varyear1).Activate
Range("names_sp_1").Copy
Windows("even-weeklymasters.xls").Activate
Range("m_sp_names_1").Activate
Selection.PasteSpecial Paste:=xlPasteValues,
Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

* Windows("Even-WeeklyMasters.xls").Activate
Sheets("Master").Select

* MsgBox ("The workbook being used to supply names, ") &
varyear1 & (" will now be closed.")

Workbooks(varyear1).Close SaveChanges:=False

The Msgbox line and the line above it will NOT execute
when run from the shortcut but does appear when the macro
is strated from the Run button or when single stepping.

HELP!!!! Why will it not run properly from the
Shortcut????


--

Dave Peterson

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
Macro works Macro does not work Wanna Learn Excel Discussion (Misc queries) 4 March 24th 08 12:51 PM
Insert Hyperlink shortcut no longer works [email protected] Links and Linking in Excel 0 February 8th 07 04:50 PM
Insert Hyperlink shortcut no longer works [email protected] Links and Linking in Excel 0 February 8th 07 04:42 PM
macro works in .xlt but not .xls BrianG[_3_] Excel Programming 6 September 18th 03 10:13 PM
A good macro that works wrong with keyboard shortcut Allen[_4_] Excel Programming 1 September 12th 03 04:37 PM


All times are GMT +1. The time now is 10:44 PM.

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

About Us

"It's about Microsoft Excel"