Live-Forum - Die aktuellen Beiträge
Datum
Titel
24.04.2024 19:29:30
24.04.2024 18:49:56
Anzeige
Archiv - Navigation
1520to1524
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

Aus Datum nur Jahres Jahr ohne doppelte einlesen

Aus Datum nur Jahres Jahr ohne doppelte einlesen
01.11.2016 19:39:32
Ludmila
Hallo,
ich möchte in eine UF-ComboBox nur die Jahres- Zahl ohne doppelte einlesen.
Meine Liste z.B
01.02.2015
03.06.2015
02.07.2016
06.08.2017
usw.
mein Versuch

Private Sub CommandButton1_Click()
Dim loEnde As Long
Dim col As New Collection
Dim iRow As Integer
Range("A2:A5").Select
Selection.Copy
Range("K2").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Selection.NumberFormat = "yyyy"
iRow = 2
On Error Resume Next
Do Until IsEmpty(Cells(iRow, 11))
col.Add Cells(iRow, 11), Cells(iRow, 11)
If Err = 0 Then
cboJahr.AddItem Cells(iRow, 11)
Else
Err.Clear
End If
iRow = iRow + 1
Loop
On Error GoTo 0
cboJahr.ListIndex = -1
End Sub

Funktioniert nicht
Danke für Eure Hilfe!
Gruß
Ludmila

3
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Aus Datum nur Jahres Jahr ohne doppelte einlesen
01.11.2016 21:01:53
fcs
Hallo Ludmilla,
du musst die Text-Eigenschaft der Zellen in Spalte 11 (K) benutzen.
      col.Add Cells(iRow, 11).Text, Cells(iRow, 11).Text
If Err = 0 Then
cboJahr.AddItem Cells(iRow, 11).Text
Else

Es geht aber auch ohne den Umweg über das Kopieren der Zellen in Spalte A.
Die Zellen in Spalte A können direkt ausgewertet werden.
LG
Franz
Private Sub CommandButton1_Click()
Dim loEnde As Long
Dim col As New Collection
Dim iRow As Integer
iRow = 2
On Error Resume Next
Do Until IsEmpty(Cells(iRow, 1))
col.Add Year(Cells(iRow, 1)), Format(Cells(iRow, 1), "YYYY")
If Err = 0 Then
cboJahr.AddItem Year(Cells(iRow, 1))
Else
Err.Clear
End If
iRow = iRow + 1
Loop
On Error GoTo 0
cboJahr.ListIndex = -1
End Sub

Anzeige
AW: Aus Datum nur Jahres Jahr ohne doppelte einlesen
01.11.2016 21:15:26
Ludmila
Hallo Case,
Hallo Franz,
Danke für die Hilfe. Beides funktioniert super.
Gruß
Ludmila

319 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige