AW: Spalten ausblenden wenn Bedingung erfüllt
21.10.2019 13:21:59
fcs
Hallo Chris,
für den Upload bitte die Hinweise bzgl Pfad, Dateiname und Dateigröße hier beachten:
https://www.herber.de/forum/file_upload.html
Nachfolgend entsprechende Makros für die gewünschte Aktion.
LG
Franz
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address(False, False, xlA1) = "C2" Then
Call Spalten_ohne_Suchwort_ausblenden(varSuch:=Target.Text, wks:=ActiveSheet, _
Spalte_1:=6, Spalte_L:=26)
End If
End Sub
'Makro in einem allgemeinen Modul oder im Code-Modul des Tabellenblatts mit dem Dropdown
Sub Spalten_ohne_Suchwort_ausblenden(ByVal varSuch As Variant, wks As Worksheet, _
ByVal Spalte_1 As Long, ByVal Spalte_L As Long, _
Optional ByVal lngLookat As Long = xlPart)
Dim Spalte As Long
Dim rngZelle As Range
With wks
If varSuch = "" Then Exit Sub
.Range(.Columns(Spalte_1), .Columns(Spalte_L)).Hidden = False
For Spalte = Spalte_L To Spalte_1 Step -1
Set rngZelle = .Columns(Spalte).Find(what:=varSuch, LookIn:=xlValues, _
lookat:=lngLookat, MatchCase:=False)
If rngZelle Is Nothing Then
.Columns(Spalte).Hidden = True
End If
Next
End With
End Sub