AW: Ich schließe mit speichern
15.12.2020 15:55:00
Nepumuk
Hallo Walter,
komisch, normalerweise speichern ActiveX-Controls auf Tabellenblättern ihre Werte. Aber bei mir verliert die ComboBox auch ihre Werte. Dann so:
Im Modul "DieseArbeitsmappe":
Option Explicit
Private Sub Workbook_Open()
Call Worksheets("Tabelle1").FillComboBox
End Sub
Im Modul der Tabelle:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim objRange As Range, objCell As Range
If Target.Address = "$A$1" Then
Call FillComboBox
Else
Set objRange = Intersect(Range("D14:D44"), Target)
If Not objRange Is Nothing Then
Application.EnableEvents = False
For Each objCell In objRange
Select Case UCase$(objCell.Text)
Case "F", "U", "UU", "K"
objCell.Value = UCase$(objCell.Text)
Call objCell.Offset(0, 1).Resize(1, 3).ClearContents
End Select
Next objCell
Set objRange = Nothing
Application.EnableEvents = True
End If
End If
End Sub
Public Sub FillComboBox()
Dim lngRow As Long
Call ComboBox1.Clear
Select Case Cells(1, 1).Value
Case 1
With Worksheets("Feiertage")
For lngRow = 4 To 20
ComboBox1.AddItem .Cells(lngRow, 9).Text & ", " & .Cells(lngRow, 10).Text
Next lngRow
End With
Case 2
With Worksheets("Feiertage")
For lngRow = 4 To 20
ComboBox1.AddItem .Cells(lngRow, 12).Text & ", " & .Cells(lngRow, 14).Text
Next lngRow
End With
End Select
End Sub
Gruß
Nepumuk