Thread: Drop Down List
View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.newusers
Pete[_5_] Pete[_5_] is offline
external usenet poster
 
Posts: 30
Default Drop Down List

On 27 Jul, 01:34, Gord Dibben <gorddibbATshawDOTca wrote:
I am surprised you are not getting error messages about "ambiguous name
detected"

More than one Worksheet_Chamge event in a sheet is not allowed.

There are ways to work around it but I'm not the guy to be talking to.

Browse through Chip's pages on Events to get a better idea of what's
available.

http://www.cpearson.com/excel/Events.aspx

And check out David McRitchie's site

http://www.mvps.org/dmcritchie/excel/event.htm

Gord

On Sat, 26 Jul 2008 13:29:01 -0700 (PDT), Pete
wrote:



Gord, perfect again exacly what I want. If I post all the code I have
in the Change Event sub, could you tidy it up for me so it works
properly. I can get the ones you have done for me to work seperately,
but when they are both in only the first one works. I also have Chip
Pearson's Quick Time Entry code in there to and I could od with all 3
working.- Hide quoted text -


- Show quoted text -


I only have the one Worksheet_Change Event Sub but would like the 2
pieces of code you have done for me to be in it. Could you combine the
2 as below as the way I have it I think the first exit's before the
second has been done.

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "C11,E11,G11,I11,K11" 'add cells to
suit
Dim cell As Range
On Error GoTo ws_exit
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If .Value < "" Then
.Value = .Value * .Offset(6, 0).Value
End If
End With
End If
ws_exit:
Application.EnableEvents = True

Set r = Range("A1") 'edit to suit the DV cell(s)
If Intersect(Target, r) Is Nothing Then
Exit Sub
End If
vals = Array("A", "B", "C", "D", "E", "F") 'edit to suit
nums = Array(1, 2, 3, 4, 5, 6) 'add more numbers
For Each rr In r
ival = 0
For i = LBound(vals) To UBound(vals)
If UCase(rr.Value) = vals(i) Then
ival = nums(i)
End If
Next
If ival 0 Then
rr.Value = ival
End If
Next

End Sub

Pete