Results 1 to 6 of 6

Code not running properly! Getting error message

Threaded View

  1. #1
    Registered User
    Join Date
    01-18-2013
    Location
    Maryland
    MS-Off Ver
    Excel 2010
    Posts
    5

    Code not running properly! Getting error message

    I am trying to make a multi value picklist so when a user selects more than one option from the drop down menu, the results show in one cell separated by commas. I found this code online and plugged it into VB on my spreadsheet and it's not working. I'm not a coding expert so I don't know what the solution is. See code below:

    Sub DataMultiSelect()
    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 = 12 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
    
    End Sub
    Last edited by arlu1201; 01-28-2013 at 01:29 PM. Reason: Added code tags.

Thread Information

Users Browsing this Thread

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

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1