LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Junior Member
 
Posts: 1
Default Multiple selection on dropdown in same cell

Dear Users

I am trying to make multiple selection of drop down values to appear in same cell

I am using VBA code

I want to do this for 2 seperate columns

When i run the code , it works perfectly for one column but not the other columns
i think the issues is with the Range

Please see source code

HTML Code:
 Private Sub Worksheet_Change(ByVal Target As Range)
   sub1_Change Target
   sub2_Change Target
End Sub


Private Sub sub1_Change(ByVal Target As Range)

Dim rngDV As Range
Dim oldVal As String
Dim newVal As String
Dim lCode As Long
Dim wsList As Worksheet
Dim rngList As Range
Dim rngListID As Range
If Target.Count  1 Then GoTo exitHandler

Set wsList = ActiveSheet
Set rngList = wsList.Range("external")
Set rngListID = wsList.Range("externalID")

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 = 8 Then
    If oldVal = "" Then
      'do nothing
         lCode = rngListID.Range("A1") _
            .Offset(Application. _
                WorksheetFunction _
                .Match(Target.Value, _
                rngList, 0) - 1, 0)
         Target.Offset(0, 1).Value = lCode
   
   Else
      If newVal = "" Then
        'do nothing
         Target.Offset(0, 1).ClearContents
      Else
         lCode = rngListID.Range("A1") _
            .Offset(Application. _
                WorksheetFunction _
                .Match(Target.Value, _
                rngList, 0) - 1, 0)
         Target.Value = oldVal _
           & ", " & newVal
         Target.Offset(0, 1).Value = Target.Offset(0, 1).Value _
           & ", " & lCode
      End If
    End If
  End If
End If

exitHandler:
  Application.EnableEvents = True
End Sub

Private Sub sub2_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 = 11 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]


Column 8 : Room used works fine
Column 11: Audience type does not seem to work.

Can you please help
 
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
How do I allow a multiple selection from a dropdown? Monica Excel Discussion (Misc queries) 11 April 17th 08 04:34 PM
Dropdown in cell base on a selection of a different drop down paapa21 Excel Programming 3 February 26th 08 11:52 PM
How do you lock a cell after making a selection from a dropdown b GuyHUf Excel Worksheet Functions 0 June 25th 07 04:06 PM
VLOOKUP or dropdown in the cell depending on selection in another Spottydog Excel Discussion (Misc queries) 1 January 31st 07 07:59 AM
Allow selection of multiple values in dropdown list in excel Nancy @ CHR Excel Discussion (Misc queries) 2 April 13th 06 10:44 PM


All times are GMT +1. The time now is 11:43 PM.

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

About Us

"It's about Microsoft Excel"