![]() |
Drop down select with same cell entry
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! |
Drop down select with same cell entry
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! |
Drop down select with same cell entry
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 |
All times are GMT +1. The time now is 01:57 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com