Results 1 to 3 of 3
  1. #1
    Thailand Expat
    astasinim's Avatar
    Join Date
    Dec 2006
    Last Online
    21-07-2019 @ 04:40 PM
    Location
    Yorkshire
    Posts
    4,067

    Any excel experts here?

    I`ve got a bit of issue setting up an excel sheet.

    Im setting up a training programme for work and have run into a problem when using "data validation".

    For instance, I have set up column A to run a drop down list using data validation. What is chosen then leads to a further data validation list in column B. This all works fine, but what if I want to select multiple options from the list?

    I have combated that by using the following code in column B
    Code:
     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 = 4 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
    Here is where I get the problem. What if want multiple selections in column A, that lead to the corrosponding sub menus. As is stands at the moment, if I apply the code to column A, Column B draws a blank.

    Any help would be much appreciated.
    Thanks
    I aint superstitious, but I know when somethings wrong
    I`ve been dragging my heels with a bitch called hope
    Let the undercurrent drag me along.

  2. #2
    Thailand Expat
    Kurgen's Avatar
    Join Date
    Mar 2006
    Last Online
    15-05-2023 @ 10:57 AM
    Location
    Shitsville
    Posts
    8,812
    press B and F5, that should sort it.

  3. #3
    Thailand Expat
    astasinim's Avatar
    Join Date
    Dec 2006
    Last Online
    21-07-2019 @ 04:40 PM
    Location
    Yorkshire
    Posts
    4,067
    Its just taking me to the sheet where all the text options are stored.

    Thanks anyway.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •