Thread: Data Validation
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default Data Validation

Susanna,

Try this


Private oldValue As String
Private Const DVCell As String = "M1"
Private Const dataList As String = "H1:H10"

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Range("dataList")) Is Nothing Then
With Target
If Range(DVCell).Value = oldValue Then
Range(DVCell).Value = .Value
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not Intersect(Target, Range(dataList)) Is Nothing Then
If Not IsEmpty(Target) Then
oldValue = Target.Value
End If
End If
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Susanna via OfficeKB.com" wrote in message
...
I have a cell (A3) that uses Data Validation.

I've managed to create a list for the Data Validation with the values:
Project A
Project B
Project C

If I add or change an entry in the list, it gets updated in the dropdown.
However, if in cell A3, I had previously selected 'Project A', and then

later
changed 'Project A' in the list to 'Project AAA', the value in cell A3
remains as 'Project A' . But I want the value in cell A3 to be

automatically
changed to 'Project AAA'.

A similar problem had been reported in the discussion thread titled 'Data
Validation/Drop down list automatic update'. Tom Ogilvy responded by

saying
a macro using a change event is required. Would you be able to provide me
with the code for this macro?

Thanks