Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jan Jan is offline
external usenet poster
 
Posts: 159
Default Data Validation Multi Select

I have set up a spreadsheet that has data validation in 2 columns. The data
validations are 2 ranges set up on a hidden worksheet. I found the below
code from contextures, which allows multi-select of data validation options
and shows the selections separated by a comma in the cell. I changed the
Target.column =5 for my specific worksheet.

I would like to somehow adapt the code to allow this same feature to work
for the 2nd column of data validation (column 6), but have yet to figure out
how to do it.
Is it possible to do? And if yes, can someone tell me how?
TIA

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 = 5 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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,979
Default Data Validation Multi Select

You can add column 6:

If Target.Column = 5 Or Target.Column = 6 Then


Jan wrote:
I have set up a spreadsheet that has data validation in 2 columns. The data
validations are 2 ranges set up on a hidden worksheet. I found the below
code from contextures, which allows multi-select of data validation options
and shows the selections separated by a comma in the cell. I changed the
Target.column =5 for my specific worksheet.

I would like to somehow adapt the code to allow this same feature to work
for the 2nd column of data validation (column 6), but have yet to figure out
how to do it.
Is it possible to do? And if yes, can someone tell me how?
TIA

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 = 5 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




--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html

  #3   Report Post  
Posted to microsoft.public.excel.programming
Jan Jan is offline
external usenet poster
 
Posts: 159
Default Data Validation Multi Select

Thank you that was it.

"Debra Dalgleish" wrote:

You can add column 6:

If Target.Column = 5 Or Target.Column = 6 Then


Jan wrote:
I have set up a spreadsheet that has data validation in 2 columns. The data
validations are 2 ranges set up on a hidden worksheet. I found the below
code from contextures, which allows multi-select of data validation options
and shows the selections separated by a comma in the cell. I changed the
Target.column =5 for my specific worksheet.

I would like to somehow adapt the code to allow this same feature to work
for the 2nd column of data validation (column 6), but have yet to figure out
how to do it.
Is it possible to do? And if yes, can someone tell me how?
TIA

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 = 5 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




--
Debra Dalgleish
Contextures
http://www.contextures.com/tiptech.html


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multi-level dependent data validation aussiemate65 Excel Discussion (Misc queries) 3 February 25th 10 11:07 PM
Past the total of select multi row data Qazi Ahmad Excel Discussion (Misc queries) 1 January 10th 07 02:57 PM
using a multi-select listbox to pull data dreamz[_6_] Excel Programming 2 October 17th 05 10:56 PM
Extract values from a multi-select multi-column list-box Peter[_20_] Excel Programming 5 September 28th 03 04:04 PM
Multi column Data Validation List Chris Excel Programming 1 September 17th 03 04:20 AM


All times are GMT +1. The time now is 04:56 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"