Make Excel List to multiselect

| | Allgemein, Programmierung, Windows

With this VBA Code you can make a Data Validation list to an multiselect list

Private Sub Worksheet_Change(ByVal Target As Range)
    '** Multiselect via Dropdown List (Validation)
    '** Insert in the code container of the relevant worksheet
    Dim rngDV As Range
    Dim oldVal As String
    Dim newVal As String
    Dim makeMultiselect As Boolean
    Dim cellsToCheck As Range
    Dim arrValues As Variant
    Dim i As Integer
    Dim found As Boolean
    Dim result As String

    '** Error handling
    On Error GoTo Errorhandling

    '** Defining the range of cells that should allow multiselect
    Set cellsToCheck = Union(Range("E21"), Range("F20"), Range("F19"))

    '** Check if the changed cell is in the defined multiselect cells range
    If Not Application.Intersect(Target, cellsToCheck) Is Nothing Then
        makeMultiselect = True
    End If

    '** Perform multiselect in the defined range
    If makeMultiselect Then
        '** Define the range
        Set rngDV = Target.SpecialCells(xlCellTypeAllValidation)
        If rngDV Is Nothing Then GoTo Errorhandling
        '** Check if a valid cell was selected and insert values
        If Not Application.Intersect(Target, rngDV) Is Nothing Then
            Application.EnableEvents = False
            newVal = Target.Value
            Application.Undo
            oldVal = Target.Value
            Target.Value = newVal
            '** Toggle logic for selecting/deselecting values
            If newVal = "" Then  ' Clearing the cell completely if Del is pressed
                Target.Value = ""
            ElseIf oldVal <> "" Then
                arrValues = Split(oldVal, ", ")
                found = False
                result = ""
                For i = LBound(arrValues) To UBound(arrValues)
                    If arrValues(i) = newVal And Not found Then
                        found = True
                    Else
                        If result = "" Then
                            result = arrValues(i)
                        Else
                            result = result & ", " & arrValues(i)
                        End If
                    End If
                Next i
                If Not found Then
                    If result = "" Then
                        result = newVal
                    Else
                        result = result & ", " & newVal
                    End If
                End If
                Target.Value = result
            End If
        End If
        Application.EnableEvents = True
    End If

Errorhandling:
    Application.EnableEvents = True
End Sub


Neueste Beiträge

Your MSPA Goes Smart – Step-by-Step to a DIY Smart Home Hot Tub (Wi-Fi Upgrade)

Introduction

In this article, I’ll show you how I successfully reverse-engineered the serial communication protocol of an MSPA Muse Carlton hot tub. The goal was to read remote control commands and send custom ones. I used an ESP32 Dev Board[*] for this. This protocol likely works with other MSPA models as well.

This article is for makers, home automation enthusiasts, and tech fans who enjoy diving deep into technical systems.


Weiter >>

Dein MSPA wird smart – Schritt-für-Schritt zum DIY Smart Home Whirlpool (WIFI/WLAN Upgrade) / Reverse Engineering eines proprietären UART-Protokolls am Beispiel eines Whirlpool-Steuergeräts (MSPA Muse Carlton)

Einleitung

In diesem Artikel zeige ich dir, wie ich das serielle Kommunikationsprotokoll eines MSPA Muse Carlton Whirlpools erfolgreich reverse-engineered habe. Ziel war es, die Fernbedienungsbefehle auszulesen und eigene Kommandos zu senden. Dafür kam ein ESP32 Dev Board[*] zum Einsatz. Dieses Protokoll funktioniert vermutlich auch bei anderen MSPA-Modellen.

Dieser Artikel richtet sich an alle Maker, Home-Automatisierer und Technik-Fans, die gern tief in die Technik eintauchen.


Weiter >>

Der perfekte Einstieg in die Welt der Vinyls: Der Denon DP-300F und 2 Alternativen

Warum Vinyl?

Vinyl erlebt seit einigen Jahren ein riesiges Comeback. Der warme, analoge Klang, das bewusste Musikhören und das Sammeln von Schallplatten faszinieren immer mehr Musikliebhaber. Dabei ist nicht nur das nostalgische Feeling ausschlaggebend, sondern vor allem auch der unverwechselbare Klangcharakter von Vinyl – ein Klang, der trotz moderner digitaler Verfahren nach wie vor viele Fans begeistert.

Denon DP-300F[*] – Der ideale Allrounder für Einsteiger

Der Denon DP-300F[*] ist nach wie vor ein beliebter vollautomatischer Plattenspieler im Einsteigerbereich. Sein automatischer Tonarm sorgt für einen schonenden Umgang mit Nadel und Platte – perfekt, wenn du ohne großen Aufwand direkt in den Vinylgenuss starten möchtest.


Weiter >>

Ein Leitfaden für Senioren: Günstige Smartphones bis 100 Euro – Unsere 4 Favoriten & Erfahrungsbericht einer maßgeschneiderten Senioren-Lösung – UPDATE 2024/25

In diesem Beitrag stellen wir dir vier günstige Smartphones vor, die aktuell (Stand Dezember 2024) für unter 100 Euro erhältlich sind. Zusätzlich teilen wir eine ganz besondere Geschichte aus dem Familienkreis: Wie wir eines dieser Geräte für die Oma meiner Verlobten eingerichtet haben, damit sie trotz ihrer Parkinson-Erkrankung gut damit zurechtkommt.


Weiter >>