Thread: Data Validation
View Single Post
  #8   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

Morning Susanna,

I have just tried it again, using the cell addresses that you used, and it
is working fine as I understand it.

I have changed the code to your data, added extra error-handling, so please
replace all the code with this and try again. Note where it gets installed.

Option Explicit

Private oldValue As String
Private Const DVCell As String = "A1"
Private Const dataList As String = "B1:B10"

Private Sub Worksheet_Change(ByVal Target As Range)

On Error GoTo ws_exit:
Application.EnableEvents = False
If Target.Count = 1 Then
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
End If

ws_exit:
Application.EnableEvents = True
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Count = 1 Then
If Not Intersect(Target, Range(dataList)) Is Nothing Then
If Not IsEmpty(Target) Then
oldValue = Target.Value
End If
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
...
Hi Bob,

I have defined cell A1 as an editable field that uses a data validation

list
for its dropdown.

The range for the data validation can be found in B1:B3 with the values:
B1 Project A
B2 Project B
B3 Project C

In cell A1, I select 'Project A' from the dropdown list. Cell A1 now has

a
value of 'Project A'.

If I change the value of B1 to 'Project AAA', I would like to see the

value
of cell A1 automatically changed to 'Project AAA', but it doesn't; the

value
of cell A1 remains to be the original 'Project A'.

Bob Phillips wrote:
Lost me Susanna.

If you change the Project A to Project AAA on the data validation list,

and
the dropdown cell is changed, what cell is it that remains unchanged?

Hi Bob,

[quoted text clipped - 18 lines]

Thanks



--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200508/1