Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to keep ONKey's macro on Worksheet Selection Change Event


Using the following VBA code I get an error message "The macr
"C:\data\MSExcel\statement.xls'!JumpToA14' cannot be found.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Range("$B9:$C$9"), Range(Target.Address)
Is Nothing Then
'To turn on enter key macro
Application.OnKey "~", "JumpToA14"
Application.OnKey "{Enter}", "JumpToA14"
'To turn off enter key macro
Else
Application.OnKey "~"
Application.OnKey "{Enter}"
End If
End Sub

Private Sub JumpToA14()
'This line seems to work better Range("A14").Activate
Application.Goto Reference:=Range("A14")
End Sub

It works great if I put the Private Sub JumpToA14() in Module 1. Doe
anybody know how I can make it work by keeping both subs unde
Worksheet selection change event? (I really want the OnKey on th
Worksheet selection change event)

Thanks a million, Mikebur

--
mikebur
-----------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...fo&userid=2458
View this thread: http://www.excelforum.com/showthread.php?threadid=40099

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,119
Default How to keep ONKey's macro on Worksheet Selection Change Event

The procedure referenced by the OnKey function must reside in a module. There
is no way around it.

FYI... Target and Range(Target.Address) are exactly the same thing. They
both are range objects.
--
HTH...

Jim Thomlinson


"mikeburg" wrote:


Using the following VBA code I get an error message "The macro
"C:\data\MSExcel\statement.xls'!JumpToA14' cannot be found.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Application.Intersect(Range("$B9:$C$9"), Range(Target.Address))
Is Nothing Then
'To turn on enter key macro
Application.OnKey "~", "JumpToA14"
Application.OnKey "{Enter}", "JumpToA14"
'To turn off enter key macro
Else
Application.OnKey "~"
Application.OnKey "{Enter}"
End If
End Sub

Private Sub JumpToA14()
'This line seems to work better Range("A14").Activate
Application.Goto Reference:=Range("A14")
End Sub

It works great if I put the Private Sub JumpToA14() in Module 1. Does
anybody know how I can make it work by keeping both subs under
Worksheet selection change event? (I really want the OnKey on the
Worksheet selection change event)

Thanks a million, Mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=400992


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to keep ONKey's macro on Worksheet Selection Change Event


Thanks a million. I'm still learning.

mikeburg


--
mikeburg
------------------------------------------------------------------------
mikeburg's Profile: http://www.excelforum.com/member.php...o&userid=24581
View this thread: http://www.excelforum.com/showthread...hreadid=400992

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
Quick VBA Worksheet Change Event or Selection Question: Damil4real Excel Worksheet Functions 6 November 17th 09 10:28 PM
Selection Change Event Jim Thomlinson[_3_] Excel Programming 0 April 28th 05 05:36 PM
Selection Change Event Jim Thomlinson[_3_] Excel Programming 3 April 28th 05 10:01 AM
Copy Sheets minus Worksheet Change Event code & Macro Buttons Bob[_36_] Excel Programming 0 October 8th 03 01:17 AM


All times are GMT +1. The time now is 11:22 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"