Results 1 to 9 of 9

Multiple Selection Data Validation and Placement of Selection.

Threaded View

  1. #1
    Registered User
    Join Date
    02-07-2012
    Location
    IN
    MS-Off Ver
    Excel 2010
    Posts
    14

    Multiple Selection Data Validation and Placement of Selection.

    I have a program in excel that allows me to do analysis/summarize data on one form by searching for terms through the use of drop down lists using data validation. I would like to be able to select multiple factors and have those selections inserted into a different column with each selection in a different row. I am able to do that with the following code adapted from the contextures website:

    
    Option Explicit
    Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo exitHandler
    
    Dim rngDV As Range
    Dim lRow As Long
    Dim lCol As Long
    Dim cRow As Long
    
    lCol = Target.Column 'column with data validation cell
    
    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
        If Target.Value = "" Then GoTo exitHandler
        Application.EnableEvents = False
        Select Case Target.Column
           Case 10
            If Target.Offset(0, 18).Value = "" Then
               lRow = Target.Row
            Else
                lRow = Cells(Rows.count, lCol + 18).End(xlUp).Row
        End If
                Cells(lRow, lCol + 18).Value = Target.Value
        End Select
    End If
    
    exitHandler:
      Application.EnableEvents = True
      
    End Sub
    My data validation list consists of jobs: Welder, Mechanic, and Janitor. (and many other fields)
    If Welder is selected, this places Welder in another column (column 18). If it is selected again, then it gets inserted into the same column and row below it. My problem is, if I were to select Welder twice, I would like it to remove the "Welder" from the column, rather than placing another instance of it in there.

    I have a decent amount of experience coding in R, but very little in VBA, and writing loops are very foreign for me. I have a general strategy how I might approach this sort of problem in R, but it will do me no good in there . Thanks in advance for your time,

    Lucas Smith
    Last edited by LCS; 02-08-2012 at 08:51 AM.

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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