Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default Event Procedure - Data Validation List

Hello,

I would like to run a bit of code whenever the contents of either of two
cells is changed. For both of these cells, changes are done via a drop-list
(data validation)....

Any help getting started would be greatly appreciated!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Event Procedure - Data Validation List

this is standard event:

in the VBA editor
in the sheet's code
use the

Private Sub Worksheet_Change(ByVal Target As Range)
End Sub

'event

inside it, you can make a
if not ( intersect( Me.Range("A1:A2"),Target) is nothing) then
' ok my cells
end if


because Target is the changed cell
(something else as been entered inside it)

  #3   Report Post  
Posted to microsoft.public.excel.programming
KL KL is offline
external usenet poster
 
Posts: 201
Default Event Procedure - Data Validation List

Hi Jeff,

You could use the Change event of the sheet where your cells are located.
Asuming that the cells are [A1] and [C1] try copying the below code into the
VBA module of the sheet in question:

Regards,
KL

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1,C1")) _
Is Nothing Then Exit Sub
MsgBox "Change detected!"
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default Event Procedure - Data Validation List

Thanks for the response... Unfortunately, it doesn't fire. Here's what I used:


Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("D3,D5")) _
Is Nothing Then Exit Sub


Do something..............



End Sub



"KL" wrote:

Hi Jeff,

You could use the Change event of the sheet where your cells are located.
Asuming that the cells are [A1] and [C1] try copying the below code into the
VBA module of the sheet in question:

Regards,
KL

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1,C1")) _
Is Nothing Then Exit Sub
MsgBox "Change detected!"
End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
KL KL is offline
external usenet poster
 
Posts: 201
Default Event Procedure - Data Validation List

Hi Jeff,

Two things to check I guess:

1) Are you sure you put this code into the module of the worksheet where you
change the cells and not in the one of ThisWorkbook, other sheet , a normal
module (such as Module1), or even a module in another workbook?

2) Are the macros enabled?

3) Have you tried to change D3 or D5?

Regards,
KL


"JEFF" wrote in message
...
Thanks for the response... Unfortunately, it doesn't fire. Here's what I
used:


Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("D3,D5")) _
Is Nothing Then Exit Sub


Do something..............



End Sub



"KL" wrote:

Hi Jeff,

You could use the Change event of the sheet where your cells are located.
Asuming that the cells are [A1] and [C1] try copying the below code into
the
VBA module of the sheet in question:

Regards,
KL

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1,C1")) _
Is Nothing Then Exit Sub
MsgBox "Change detected!"
End Sub







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default Event Procedure - Data Validation List

Yes to all three

"KL" wrote:

Hi Jeff,

Two things to check I guess:

1) Are you sure you put this code into the module of the worksheet where you
change the cells and not in the one of ThisWorkbook, other sheet , a normal
module (such as Module1), or even a module in another workbook?

2) Are the macros enabled?

3) Have you tried to change D3 or D5?

Regards,
KL


"JEFF" wrote in message
...
Thanks for the response... Unfortunately, it doesn't fire. Here's what I
used:


Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("D3,D5")) _
Is Nothing Then Exit Sub


Do something..............



End Sub



"KL" wrote:

Hi Jeff,

You could use the Change event of the sheet where your cells are located.
Asuming that the cells are [A1] and [C1] try copying the below code into
the
VBA module of the sheet in question:

Regards,
KL

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1,C1")) _
Is Nothing Then Exit Sub
MsgBox "Change detected!"
End Sub






  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Event Procedure - Data Validation List

other possibility:
are the events enabled ?

Application.EnableEvents = true

you can check the event macro is called by adding a
beep
or a
msgbox "ok"
at the very beginning of the macro
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Event Procedure - Data Validation List

What version of excel are you running?

If it's xl97, take a look at Debra Dalgleish's warning:
http://www.contextures.com/xlDataVal08.html#Change

JEFF wrote:

Thanks for the response... Unfortunately, it doesn't fire. Here's what I used:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("D3,D5")) _
Is Nothing Then Exit Sub


Do something..............


End Sub


"KL" wrote:

Hi Jeff,

You could use the Change event of the sheet where your cells are located.
Asuming that the cells are [A1] and [C1] try copying the below code into the
VBA module of the sheet in question:

Regards,
KL

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1,C1")) _
Is Nothing Then Exit Sub
MsgBox "Change detected!"
End Sub




--

Dave Peterson
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default Event Procedure - Data Validation List

Hi Dave,

I'm using Excel 2003... I even tried pasting the below (found in Debra's
website) into a new workbook, but no luck.....



Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$2" Then
ActiveWindow.Zoom = 120
Else
ActiveWindow.Zoom = 100
End If
End Sub




"Dave Peterson" wrote:

What version of excel are you running?

If it's xl97, take a look at Debra Dalgleish's warning:
http://www.contextures.com/xlDataVal08.html#Change

JEFF wrote:

Thanks for the response... Unfortunately, it doesn't fire. Here's what I used:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("D3,D5")) _
Is Nothing Then Exit Sub


Do something..............


End Sub


"KL" wrote:

Hi Jeff,

You could use the Change event of the sheet where your cells are located.
Asuming that the cells are [A1] and [C1] try copying the below code into the
VBA module of the sheet in question:

Regards,
KL

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1,C1")) _
Is Nothing Then Exit Sub
MsgBox "Change detected!"
End Sub




--

Dave Peterson

  #10   Report Post  
Posted to microsoft.public.excel.programming
KL KL is offline
external usenet poster
 
Posts: 201
Default Event Procedure - Data Validation List

that's weird :-)

Are you sure you don't have the macro security set to High (menu
ToolsMacroSecurity)?

KL


"JEFF" wrote in message
...
Hi Dave,

I'm using Excel 2003... I even tried pasting the below (found in Debra's
website) into a new workbook, but no luck.....



Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$A$2" Then
ActiveWindow.Zoom = 120
Else
ActiveWindow.Zoom = 100
End If
End Sub




"Dave Peterson" wrote:

What version of excel are you running?

If it's xl97, take a look at Debra Dalgleish's warning:
http://www.contextures.com/xlDataVal08.html#Change

JEFF wrote:

Thanks for the response... Unfortunately, it doesn't fire. Here's what
I used:

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("D3,D5")) _
Is Nothing Then Exit Sub

Do something..............

End Sub

"KL" wrote:

Hi Jeff,

You could use the Change event of the sheet where your cells are
located.
Asuming that the cells are [A1] and [C1] try copying the below code
into the
VBA module of the sheet in question:

Regards,
KL

Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("A1,C1")) _
Is Nothing Then Exit Sub
MsgBox "Change detected!"
End Sub




--

Dave Peterson





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
Validation Procedure with a worksheet change event Bhupinder Rayat Excel Worksheet Functions 2 October 3rd 07 05:18 PM
Sheet change event and list validation question Nick Excel Programming 1 October 21st 04 01:20 PM
sheetChange event and list validation Nick Excel Programming 1 October 20th 04 10:34 PM
MS Bug? Data validation list dropdown with Worksheet_Change event Dan Frederick Excel Programming 0 April 6th 04 05:35 AM
OnTime event not firing in Workbook_Open event procedure GingerTommy Excel Programming 0 September 24th 03 03:18 PM


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