Gruppe
Dialog
Problem
Wie kann ich Spalten verschiedener Tabellenblätter je nach Vorgabe in ListBoxes eines UserForm-MultiPage-Steuerelements ein- und ausblenden?
StandardModule: basMain
Sub CallForm()
frmTabellen.Show
End Sub
ClassModule: frmTabellen
Private Sub cmdWeiter_Click()
Unload Me
End Sub
Private Sub lst1_Change()
Call EinAus(MultiPage1.Value + 1)
End Sub
Private Sub lst2_Change()
Call EinAus(MultiPage1.Value + 1)
End Sub
Private Sub MultiPage1_Change()
Worksheets(MultiPage1.Value + 2).Select
End Sub
Private Sub UserForm_Initialize()
lst1.Column = Worksheets("Tabelle1").Range("A1").CurrentRegion.Value
lst2.Column = Worksheets("Tabelle2").Range("A1").CurrentRegion.Value
Worksheets("Tabelle1").Range("A1").CurrentRegion.Columns.Hidden = True
Worksheets("Tabelle2").Range("A1").CurrentRegion.Columns.Hidden = True
Worksheets("Tabelle1").Select
MultiPage1.Value = 0
End Sub
Private Sub EinAus(iSheet As Integer)
Dim iCounter As Integer
With Controls("lst" & iSheet)
For iCounter = 0 To .ListCount - 1
Columns(iCounter + 1).Hidden = _
Not .Selected(iCounter)
Next iCounter
Cells(1, 1).Activate
End With
End Sub