Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1532to1536
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Monate in Kombinationsfeld

Monate in Kombinationsfeld
17.01.2017 12:25:12
Uwe
Hallo,
in einer Tabelle habe ich Datumswerte:
16.11.2016
15.01.2017
20.01.2017
02.02.2017
.....
In einem Kombinationsfeld soll dann der Monat nur einmal vorkommen
Nov 2016
Jan 2017
Feb 2017
Um die Daten dann auswerten zu können brauche ich ein Datum, entweder den Monstsersten oder den ersten Wert im Monat in column1.
Das wäre dann
als Variante 1:
Nov 2016,01.11.2016
Jan 2017,01.01.2017
Feb 2017,01.02.2017
oder
Nov 2016,16.11.2016
Jan 2017,15.01.2017
Feb 2017,02.02.2017
Gruß
Uwe

1
Beitrag zum Forumthread
Beitrag zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Monate in Kombinationsfeld
17.01.2017 12:53:01
ChrisL
Hi Uwe
Werte in Tabelle1, Spalte A. 1xUserform, 1xCombobox
Private Sub ComboBox1_Change()
Dim bytMonate As Byte, datAuswahl As Date
For bytMonate = 1 To 12
If Left(ComboBox1, 3) = Format(DateSerial(2017, bytMonate, 1), "MMM") Then
Exit For
End If
Next bytMonate
datAuswahl = DateSerial(Right(ComboBox1, 4), bytMonate, 1)
MsgBox datAuswahl
End Sub

Private Sub UserForm_Initialize()
Dim iZeile As Long, iCBIndex As Long
Dim bVorhanden As Boolean
With Worksheets("Tabelle1")
For iZeile = 1 To .Cells(Rows.Count, 1).End(xlUp).Row
bVorhanden = False
For iCBIndex = 0 To ComboBox1.ListCount - 1
If Format(.Cells(iZeile, 1), "MMM YYYY") = ComboBox1.List(iCBIndex) Then
bVorhanden = True
Exit For
End If
Next iCBIndex
If Not bVorhanden Then ComboBox1.AddItem Format(.Cells(iZeile, 1), "MMM YYYY")
Next iZeile
End With
End Sub

cu
Chris
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige