Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Validation Procedure with a worksheet change event | Excel Worksheet Functions | |||
Sheet change event and list validation question | Excel Programming | |||
sheetChange event and list validation | Excel Programming | |||
MS Bug? Data validation list dropdown with Worksheet_Change event | Excel Programming | |||
OnTime event not firing in Workbook_Open event procedure | Excel Programming |