Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I'm using the SameCell code from http://www.contextures.com/DataValMultiSelect.zip ################################################## # Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim rngDV As Range Dim oldVal As String Dim newVal As String If Target.Count 1 Then GoTo exitHandler On Error Resume Next Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation) On Error GoTo exitHandler If rngDV Is Nothing Then GoTo exitHandler If Intersect(Target, rngDV) Is Nothing Then 'do nothing Else Application.EnableEvents = False newVal = Target.Value Application.Undo oldVal = Target.Value Target.Value = newVal If Target.Column = 3 Then If oldVal = "" Then 'do nothing Else If newVal = "" Then 'do nothing Else Target.Value = oldVal _ & ", " & newVal End If End If End If End If exitHandler: Application.EnableEvents = True End Sub ################################################## # I would like to have this same code extended to the next column as well. Can someone advice on how to do that?Thanks! |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I would think the only thing you need to do is change
from: If Target.Column = 3 Then to: If (Target.Column = 3) or (Target.Column = 4) Then "Stephan" wrote: Hi, I'm using the SameCell code from http://www.contextures.com/DataValMultiSelect.zip ################################################## # Option Explicit Private Sub Worksheet_Change(ByVal Target As Range) Dim rngDV As Range Dim oldVal As String Dim newVal As String If Target.Count 1 Then GoTo exitHandler On Error Resume Next Set rngDV = Cells.SpecialCells(xlCellTypeAllValidation) On Error GoTo exitHandler If rngDV Is Nothing Then GoTo exitHandler If Intersect(Target, rngDV) Is Nothing Then 'do nothing Else Application.EnableEvents = False newVal = Target.Value Application.Undo oldVal = Target.Value Target.Value = newVal If Target.Column = 3 Then If oldVal = "" Then 'do nothing Else If newVal = "" Then 'do nothing Else Target.Value = oldVal _ & ", " & newVal End If End If End If End If exitHandler: Application.EnableEvents = True End Sub ################################################## # I would like to have this same code extended to the next column as well. Can someone advice on how to do that?Thanks! |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
thanks Joel, that worked out nicely!!
"Joel" wrote: I would think the only thing you need to do is change from: If Target.Column = 3 Then to: If (Target.Column = 3) or (Target.Column = 4) Then |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
how do I link a drop down list entry to a new drop down cell? | Excel Discussion (Misc queries) | |||
Can a user select more than one entry in a drop down list? | Excel Worksheet Functions | |||
? sort data in a drop down box w/ initial cell entry | Excel Worksheet Functions | |||
Are drop-down menus that allow 1 entry per cell possible? | Excel Discussion (Misc queries) | |||
Select a column based on a cell entry | Excel Programming |