PC Review


Reply
Thread Tools Rate Thread

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

 
 
George
Guest
Posts: n/a
 
      17th Jul 2009
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?
--
George
 
Reply With Quote
 
 
 
 
George
Guest
Posts: n/a
 
      17th Jul 2009

--
George


"stanleydgromjr" wrote:

>
> 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
>
>
> --
> stanleydgromjr
> ------------------------------------------------------------------------
> stanleydgromjr's Profile: http://www.thecodecage.com/forumz/member.php?userid=503
> View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=117182
>
>

 
Reply With Quote
 
George
Guest
Posts: n/a
 
      17th Jul 2009
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

--
George


"Simon Lloyd" wrote:

>
> George, are you getting an error? if so what is it?
>
> George;421132 Wrote:
> > 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?
> > --
> > George

>
>
> --
> Simon Lloyd
>
> Regards,
> Simon Lloyd
> 'The Code Cage' (http://www.thecodecage.com)
> ------------------------------------------------------------------------
> Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
> View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=117182
>
>

 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      17th Jul 2009
Drop the shift key from your shortcut key and you'll be set.

George wrote:
>
> 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
>
> --
> George
>
> "Simon Lloyd" wrote:
>
> >
> > George, are you getting an error? if so what is it?
> >
> > George;421132 Wrote:
> > > 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?
> > > --
> > > George

> >
> >
> > --
> > Simon Lloyd
> >
> > Regards,
> > Simon Lloyd
> > 'The Code Cage' (http://www.thecodecage.com)
> > ------------------------------------------------------------------------
> > Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
> > View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=117182
> >
> >


--

Dave Peterson
 
Reply With Quote
 
john
Guest
Posts: n/a
 
      17th Jul 2009
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
--
jb


"George" wrote:

> 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
>
> --
> George
>
>
> "Simon Lloyd" wrote:
>
> >
> > George, are you getting an error? if so what is it?
> >
> > George;421132 Wrote:
> > > 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?
> > > --
> > > George

> >
> >
> > --
> > Simon Lloyd
> >
> > Regards,
> > Simon Lloyd
> > 'The Code Cage' (http://www.thecodecage.com)
> > ------------------------------------------------------------------------
> > Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
> > View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=117182
> >
> >

 
Reply With Quote
 
George
Guest
Posts: n/a
 
      17th Jul 2009
The "shift" was the problem. Thanks for the help.
--
George


"john" wrote:

> 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
> --
> jb
>
>
> "George" wrote:
>
> > 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
> >
> > --
> > George
> >
> >
> > "Simon Lloyd" wrote:
> >
> > >
> > > George, are you getting an error? if so what is it?
> > >
> > > George;421132 Wrote:
> > > > 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?
> > > > --
> > > > George
> > >
> > >
> > > --
> > > Simon Lloyd
> > >
> > > Regards,
> > > Simon Lloyd
> > > 'The Code Cage' (http://www.thecodecage.com)
> > > ------------------------------------------------------------------------
> > > Simon Lloyd's Profile: http://www.thecodecage.com/forumz/member.php?userid=1
> > > View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=117182
> > >
> > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Key combinations not used by Excel to use in macro keyboard shortcuts? StargateFanFromWork Microsoft Excel Programming 5 14th Sep 2007 09:47 PM
Completely Exit Excel Macro =?Utf-8?B?Um9i?= Microsoft Excel Misc 3 13th Jul 2007 12:56 PM
Is it possible to exit Excel completely from a macro? =?Utf-8?B?c2FsdDQxNw==?= Microsoft Excel Programming 2 15th Dec 2006 08:57 PM
keyboard completely locked up =?Utf-8?B?a2Rlc2VtcGxl?= Microsoft Word Document Management 1 29th Nov 2005 05:56 PM
Machine works fine with USB keyboard, completely unusable with a PS2 keyboard Paul Dolen Microsoft Windows 2000 Deployment 0 23rd Aug 2004 02:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:16 PM.