How do I get an Excel macro to run completely using the keyboard?

G

George

I created an Excel macro. If I go to Tools - Macro- Select macro - Run, the
macro runs to completion. If I start the macro using the keyboard shortcut
that I defined when I recorded the macro, it executes the first line of the
macro and then stops. It acts as though I was "Stepping" through the macro.
What do I need to do to get the macro to run to completion using the keyboard
shortcut?
 
G

George

--
George


stanleydgromjr said:
George,

Please post your macro code.

At the beginning of your posted code, *enter the following without the
quote marks*:
["code"]


Sub Daily()
'
' Daily Macro
' Macro recorded 7/1/2009 by George Clovis
'
' Keyboard Shortcut: Ctrl+Shift+D
'
ChDir "C:\Documents and Settings\George\My Documents\WEIGHT"
Workbooks.Open Filename:= _
"C:\Documents and Settings\George\My Documents\WEIGHT\Exercise.xls"
Workbooks.Open Filename:= _
"C:\Documents and Settings\George\My Documents\WEIGHT\2009dietpl.xls"
ChDir "C:\Documents and Settings\George\My Documents\MEDICAL"
Workbooks.Open Filename:= _
"C:\Documents and Settings\George\My
Documents\MEDICAL\GeorgeBloodPressure.XLS"
End Sub
At the end of your posted code, *enter the following without the quote
marks*:
["/code"]


Have a great day,
Stan
 
G

George

I get no error. The code is simple. It opens three spreadsheets. What
happens, it opens the first spreadsheet and stops. The code follows:

Sub Daily()
'
' Daily Macro
' Macro recorded 7/1/2009 by George Clovis
'
' Keyboard Shortcut: Ctrl+Shift+D
'
ChDir "C:\Documents and Settings\George\My Documents\WEIGHT"
Workbooks.Open Filename:= _
"C:\Documents and Settings\George\My Documents\WEIGHT\Exercise.xls"
Workbooks.Open Filename:= _
"C:\Documents and Settings\George\My Documents\WEIGHT\2009dietpl.xls"
ChDir "C:\Documents and Settings\George\My Documents\MEDICAL"
Workbooks.Open Filename:= _
"C:\Documents and Settings\George\My
Documents\MEDICAL\GeorgeBloodPressure.XLS"
End Sub
 
J

john

I think using Ctrl+Shift+ causes problems - try removing Shift from your
shortcut.

Another way you could do your macro:

Sub Daily()
Dim FName()

FName = Array("C:\Documents and Settings\George\My
Documents\WEIGHT\Exercise.xls", _
"C:\Documents and Settings\George\My Documents\WEIGHT\2009dietpl.xls", _
"C:\Documents and Settings\George\My
Documents\MEDICAL\GeorgeBloodPressure.XLS")

Application.ScreenUpdating = False

For na = 0 To 2

Workbooks.Open Filename:=FName(na)

ThisWorkbook.Activate

Next na

Application.ScreenUpdating = True

End Sub
 

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