Ctrl+A macro fix for problem in Excel 2003

D

David McRitchie

Ctrl+A macro fix for problem in Excel 2003
-------------------------------------------------------------

Restore normal Ctrl+A before risking your data. Ctrl+A has always
meant one thing (Select everything) in all PC applications that have
any selection or editing ability. Excel 2003 has deviated from this
standard.

The Excel developers decided that Excel 2003 would have
a double meaning for Ctrl+A there is only one other shortcut
that I know of with two meanings and that one was a toggle (Ctr+`).
Click Ctrl+A once and you get Ctrl+* (current region), click it
twice and you get what you expect (select everything: data & shapes).

The following macro uses application.RecordMacro to
generate the code that you would not otherwise see within a
recorded macro when a macro was invoked / embedded
(recording embedded macros was done prior to Excel 2000).

Naturally it is not the *best* solution because if you have macros
turned off in Excel 2003 you place your data at risk by not getting
what you expect.

Sub Ctrl_A()
'Excel 2003 Ctrl+A is FUBAR·ed in Excel 2003
' use this shortcut to cut your loses, (D.McR 2004-06-16)
' BEFORE you destroy your data integrity.
'Ctrl+A is fixed on this machine if assigned to Ctrl+A
'You must preserve the active cell or use of Ctrl+A
' for normal use such a preselecting a cell before Ctrl+A, then sort
Dim acell As Range
Set acell = ActiveCell
Cells.select
Application.RecordMacro "'Comment from Ctrl_A in " _
& ThisWorkbook.Name
Application.RecordMacro "Cells.Select ' Ctrl_A"
acell.Activate
Application.RecordMacro "Range(""" & acell.Address(0, 0) _
& """).activate ' Ctrl_A"
Beep 'if you want to indicate restored usage
End Sub

The above have been included included on an Excel 2003 topic on my
Shortcut Keys in Excel
http://www.mvps.org/dmcritchie/excel/shortx2k.htm#foobar
 
D

Dave Peterson

Maybe just assigning the macro to an .onkey procedure:

Option Explicit
Sub auto_open()
Application.OnKey "^a", "myCtrlA"
End Sub
Sub auto_close()
Application.OnKey "^a"
End Sub
Sub myCtrlA()
Dim myCell As Range
Set myCell = ActiveCell
ActiveSheet.Cells.Select
myCell.Activate
End Sub
 
D

David McRitchie

Hi Dave,
The reason for the largeness of the macro is for macro recording
to record what the macro did, plus the comments.

Is there a particular advantage of using of onkey over assigning
a shortcut to the macro. I have in the back of mind, don't know why,
that onkey was something to avoid unless you had to use it.
Is the advantage of onkey that it would not be in the toolbars file,
ease of use, or speed?


Dave Peterson said:
Maybe just assigning the macro to an .onkey procedure:

Option Explicit
Sub auto_open()
Application.OnKey "^a", "myCtrlA"
End Sub
Sub auto_close()
Application.OnKey "^a"
End Sub
Sub myCtrlA()
Dim myCell As Range
Set myCell = ActiveCell
ActiveSheet.Cells.Select
myCell.Activate
End Sub


David said:
Restore normal Ctrl+A before risking your data. Ctrl+A has always
meant one thing (Select everything) in all PC applications that have
any selection or editing ability. Excel 2003 has deviated from this
standard.
[clipped......]
The above have been included included on an Excel 2003 topic on my
Shortcut Keys in Excel
http://www.mvps.org/dmcritchie/excel/shortx2k.htm#foobar
 
D

Dave Peterson

No reason (that I know). I guess I just find it easier sometimes to put it in
code than to explain how to do it via the user interface.

David said:
Hi Dave,
The reason for the largeness of the macro is for macro recording
to record what the macro did, plus the comments.

Is there a particular advantage of using of onkey over assigning
a shortcut to the macro. I have in the back of mind, don't know why,
that onkey was something to avoid unless you had to use it.
Is the advantage of onkey that it would not be in the toolbars file,
ease of use, or speed?


Dave Peterson said:
Maybe just assigning the macro to an .onkey procedure:

Option Explicit
Sub auto_open()
Application.OnKey "^a", "myCtrlA"
End Sub
Sub auto_close()
Application.OnKey "^a"
End Sub
Sub myCtrlA()
Dim myCell As Range
Set myCell = ActiveCell
ActiveSheet.Cells.Select
myCell.Activate
End Sub


David said:
Restore normal Ctrl+A before risking your data. Ctrl+A has always
meant one thing (Select everything) in all PC applications that have
any selection or editing ability. Excel 2003 has deviated from this
standard.
[clipped......]
The above have been included included on an Excel 2003 topic on my
Shortcut Keys in Excel
http://www.mvps.org/dmcritchie/excel/shortx2k.htm#foobar
 
D

David McRitchie

Thanks, never would have guessed that aspect. I know you still
had to use oncode for keys you can't use in the user interface.
 

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