Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 313
Default run macro on selection change

I would like to execute my macro when I will modify data in selected cell. I
would like to use selection change even as the trigger. How I can do it ?
Thanks for help.

Tony
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default run macro on selection change

right click on the sheet tab and select view code. In the left dropdown
select worksheet. In the right dropdown, select selectionchange

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

End Sub

put your commands there.

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
On Error goto ErrHandler
If target.Address = "$A$9" then
Application.EnableEvents = False


End If


ErrHandler:
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy


"Tony" wrote in message
...
I would like to execute my macro when I will modify data in selected cell.

I
would like to use selection change even as the trigger. How I can do it ?
Thanks for help.

Tony



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 313
Default run macro on selection change

Hi Tom,

Thank you for help. But it is not exactly what I need. I would like the
macro to execute when I am leaving this cell, not when I am entering. Could
you please help me a bit more. Thank you.

Regards,

Tony

"Tom Ogilvy" wrote:

right click on the sheet tab and select view code. In the left dropdown
select worksheet. In the right dropdown, select selectionchange

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

End Sub

put your commands there.

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
On Error goto ErrHandler
If target.Address = "$A$9" then
Application.EnableEvents = False


End If


ErrHandler:
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy


"Tony" wrote in message
...
I would like to execute my macro when I will modify data in selected cell.

I
would like to use selection change even as the trigger. How I can do it ?
Thanks for help.

Tony




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default run macro on selection change

A start would be to not say selectionchange when you mean Change <g:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error goto ErrHandler
If target.Address = "$A$9" then
Application.EnableEvents = False


End If


ErrHandler:
Application.EnableEvents = True
End Sub


--
Regards,
Tom Ogilvy


"Tony" wrote in message
...
Hi Tom,

Thank you for help. But it is not exactly what I need. I would like the
macro to execute when I am leaving this cell, not when I am entering.

Could
you please help me a bit more. Thank you.

Regards,

Tony

"Tom Ogilvy" wrote:

right click on the sheet tab and select view code. In the left dropdown
select worksheet. In the right dropdown, select selectionchange

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

End Sub

put your commands there.

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
On Error goto ErrHandler
If target.Address = "$A$9" then
Application.EnableEvents = False


End If


ErrHandler:
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy


"Tony" wrote in message
...
I would like to execute my macro when I will modify data in selected

cell.
I
would like to use selection change even as the trigger. How I can do

it ?
Thanks for help.

Tony






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 313
Default run macro on selection change

Thank you for help. I have it working now.

Regards,

Tony

"Tom Ogilvy" wrote:

A start would be to not say selectionchange when you mean Change <g:

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error goto ErrHandler
If target.Address = "$A$9" then
Application.EnableEvents = False


End If


ErrHandler:
Application.EnableEvents = True
End Sub


--
Regards,
Tom Ogilvy


"Tony" wrote in message
...
Hi Tom,

Thank you for help. But it is not exactly what I need. I would like the
macro to execute when I am leaving this cell, not when I am entering.

Could
you please help me a bit more. Thank you.

Regards,

Tony

"Tom Ogilvy" wrote:

right click on the sheet tab and select view code. In the left dropdown
select worksheet. In the right dropdown, select selectionchange

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

End Sub

put your commands there.

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
On Error goto ErrHandler
If target.Address = "$A$9" then
Application.EnableEvents = False


End If


ErrHandler:
Application.EnableEvents = True
End Sub

--
Regards,
Tom Ogilvy


"Tony" wrote in message
...
I would like to execute my macro when I will modify data in selected

cell.
I
would like to use selection change even as the trigger. How I can do

it ?
Thanks for help.

Tony






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
How to keep ONKey's macro on Worksheet Selection Change Event mikeburg[_21_] Excel Programming 2 September 1st 05 01:59 PM
Saving copied info while running a Selection Change Macro J Streger Excel Programming 1 April 5th 05 12:33 AM
Macro to change list box input range based on selection made in another cell Sue[_6_] Excel Programming 3 October 7th 04 06:45 PM
Selection change: How to run a Macro Maria[_6_] Excel Programming 1 March 2nd 04 12:57 PM
Macro to only change selection Del[_3_] Excel Programming 3 December 16th 03 04:30 PM


All times are GMT +1. The time now is 07:07 AM.

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

About Us

"It's about Microsoft Excel"