Data validation pull down not recognized
I am trying to start a macro (that does various things) each time data is changed in a cell (or any cell in a range of cells)
In cells a1:a3 I am using a pull down list for validation, and getting the list from an adjacent range of cells.
When I enter a value on the list manually (type it in) and then hit enter, the macros all run fine. However, when I use the pull down to enter the value (regardless of hitting enter or not), the macros do not run.
Why?
Here is the code and the workbook is attached.
[VBA]
Sub auto_open()
' Run the macro DidCellsChange any time a entry is made in a
' cell in Sheet1.
ThisWorkbook.Worksheets("Sheet1").OnEntry = "DidCellsChange"
End Sub
Sub DidCellsChange()
Dim KeyCells As String
' Define which cells should trigger the KeyCellsChanged macro.
KeyCells = "A1:A3"
' If the Activecell is one of the key cells, call the
' Test2 macro.
If Not Application.Intersect(ActiveCell, Range(KeyCells)) _
Is Nothing Then KeyCellsChanged
End Sub
Sub KeyCellsChanged()
'performs the data comparison and format changes to reflect changes
'in cell range a1:a3
'Result: appears to work just fine
Dim Cell As Object
Dim r, rprev, cprev, c, ccompr, rcompr As Integer
'Starting counter number for previous name dataset,
'corresponding cell row
rcompr = 7
'Starting counter number for previous name dataset,
'corresponding cell column
ccompr = 6
' If none of the names in A1:C1 are "NO SERVER"
For Each Cell In Range("A1:A3")
If Cell <> "NO SERVER" Then
'Find the cell with the matching name and store
'the row number as r
r = Worksheets("Sheet1").Columns(3).Find(Cell).Row
'Find the cell with the matching name and store
'the column number as c
c = Worksheets("Sheet1").Columns(3).Find(Cell).Column
'If the new name and old name are not equal...
If Worksheets("sheet1").Cells(rcompr, ccompr).Value <> Cell Then
'find the row number of the matching previous name
'and store as rprev
rprev = Worksheets("Sheet1").Columns(3).Find(Worksheets("sheet1").Cells(rcompr, ccompr).Value).Row
'find the column number of the matching previous name
'and store as cprev
cprev = Worksheets("Sheet1").Columns(3).Find(Worksheets("sheet1").Cells(rcompr, ccompr).Value).Column
'turn the old name to color none
Worksheets("Sheet1").Cells(rprev, cprev).Interior.ColorIndex = xlNone
'turn the new name to color 3 on the color chart
Worksheets("Sheet1").Cells(r, c).Interior.ColorIndex = 3
'Store the new name in the correpsonding position of previous values
Worksheets("sheet1").Cells(rcompr, ccompr).Value = Cell
'add one to old name list column number
ccompr = ccompr + 1
End If
End If
Next Cell
End Sub
[/VBA]