LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Cell value change to trigger macro (worksheet change event?)

Hi! I have a cell named "Question_Number" which can take any integer value
from 1 to 20.

There are several ways to change the value of this cell:
1) Typing in a new number manually
2) Using the scroll bar to increase or decrease the value
3) As a result of various macros from pressing buttons within the sheet.

I'd like to be able to trigger an event if this value alters. E.g. if it was
previously 3, and it is then increased or decreased. If the macro puts a 3
back in, or the user types 3 into the cell manually, I don't want anything to
happen.

I have already written the code for the changes I want to take place
afterwards, but don't know enough about events and coding to get the event
triggered in teh first place.

Any chance somebody could show me the code I need to put in?

Does it start as follows?...


Private Sub Worksheet_Change(ByVal Target As Excel.Range)

If Target.Address = "Question_Number" Then
Application.EnableEvents = False
If Target.Value ........
etc...
Else
etc... (do I put a "Nothing" or something like that here?)
End If
Application.EnableEvents = True
End If


Or am I completely wrong with this?


Also, how would I adapt it if I wanted the event to be triggered even if the
same value is put back in e.g. it was previously a 3, the macro gives another
3 and the event still triggers?

I'd be very grateful for some help!
Thanks, Neil

 
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
Trigger Event on Format Change Zone[_3_] Excel Discussion (Misc queries) 4 August 25th 07 05:43 PM
How to keep ONKey's macro on Worksheet Selection Change Event mikeburg[_21_] Excel Programming 2 September 1st 05 01:59 PM
Change Cell from Validated List Not Firing Worksheet Change Event [email protected] Excel Programming 3 October 4th 04 03:00 AM
Trigger an event on Checkbox change James Geniti Excel Programming 0 September 1st 04 09:24 PM
Trigger an event on Checkbox change James[_28_] Excel Programming 2 September 1st 04 08:31 PM


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