Changes between Version 7 and Version 8 of UserGuidelines/Importer/Excel


Ignore:
Timestamp:
05/03/18 10:31:39 (4 years ago)
Author:
Fran Boon
Comment:

Multi-Select Dropdowns

Legend:

Unmodified
Added
Removed
Modified
  • UserGuidelines/Importer/Excel

    v7 v8  
    3838}}}
    3939
     40== Multi-Select Dropdowns ==
     41* http://www.contextures.com/excel-data-validation-multiple.html
     42{{{
     43Private Sub Worksheet_Change(ByVal Target As Range)
     44' Developed by Contextures Inc.
     45' www.contextures.com
     46'code runs on protected sheet
     47Dim oldVal As String
     48Dim newVal As String
     49Dim strSep As String
     50Dim strType As Long
     51
     52'add comma and space between items
     53strSep = ", "
     54
     55If Target.Count > 1 Then GoTo exitHandler
     56
     57'checks validation type of target cell
     58'type 3 is a drop down list
     59On Error Resume Next
     60strType = Target.Validation.Type
     61
     62If Target.Column = 3 And strType = 3 Then
     63  Application.EnableEvents = False
     64  newVal = Target.Value
     65  Application.Undo
     66  oldVal = Target.Value
     67  If oldVal = "" Or newVal = "" Then
     68    Target.Value = newVal
     69  Else
     70    Target.Value = oldVal _
     71      & strSep & newVal
     72  End If
     73End If
     74
     75exitHandler:
     76  Application.EnableEvents = True
     77End Sub
     78}}}
     79
     80
    4081== Examples ==
    4182* [http://eden.sahanafoundation.org/raw-attachment/wiki/UserGuidelines/Importer/Excel/Volunteer%20Import%20Template%20(mg).xlsm Volunteers for Malagasy Red Cross]