ich eine Userform haben, dass, wenn initilised sucht nach Dateien auf unserem Server und füllt ein Kombinationsfeld über:ersten Wert in Kombinationsfeld in Userform (Excel 2013)
cmbReportDateTime.AddItem Format(reportDateTime, "ddd dd-mmm-yy hh00")
Wer weiß, wenn ich abrufen kann Der erste Wert des Kombinationsfelds (nachdem das Populationsmakro abgeschlossen wurde) später im Skript.
Ich habe Dinge ähnlich wie unten versucht (wie von anderen Websites vorgeschlagen), aber es funktioniert nicht.
me.cmbReportDateTime.Item(1).value
me.cmbReportDateTime.ItemData(1).value
vollständige Code:
Private Sub populate_reportDateTimes()
DoEvents
Application.StatusBar = "Searching for archived files... Please Wait..."
ii = 1
ThisWorkbook.Worksheets("Lookups").Range("Z1:Z100").ClearContents
cmbReportDateTime.Clear
currentDateTime = Now
reportDateTime = currentDateTime
While reportDateTime > currentDateTime - 1
report_hour = Hour(reportDateTime)
If report_hour > 20 Then
reportDateTime = Round(reportDateTime) + 20/24
ElseIf report_hour < 7 Then
reportDateTime = Round(reportDateTime - 1) + 20/24
End If
If Dir(r04Dir & r04Prefix & 1 & "_GAS_*" & UCase(Format(reportDateTime, "dd_mmm_yyyy_hh")) & "*.csv") <> "" And _
Dir(r04Dir & r04Prefix & 2 & "_GAS_*" & UCase(Format(reportDateTime, "dd_mmm_yyyy_hh")) & "*.csv") <> "" And _
Dir(r04Dir & r04Prefix & 3 & "_GAS_*" & UCase(Format(reportDateTime, "dd_mmm_yyyy_hh")) & "*.csv") <> "" And _
Dir(r04Dir & r04Prefix & 4 & "_GAS_*" & UCase(Format(reportDateTime, "dd_mmm_yyyy_hh")) & "*.csv") <> "" And _
Dir(r04Dir & r04Prefix & 5 & "_GAS_*" & UCase(Format(reportDateTime, "dd_mmm_yyyy_hh")) & "*.csv") <> "" And _
Dir(r04Dir & r04Prefix & 6 & "_GAS_*" & UCase(Format(reportDateTime, "dd_mmm_yyyy_hh")) & "*.csv") <> "" And _
Dir(r04Dir & r04Prefix & 7 & "_GAS_*" & UCase(Format(reportDateTime, "dd_mmm_yyyy_hh")) & "*.csv") <> "" And _
Dir(stpDir & stpPrefix & "Uddingston_" & Format(reportDateTime, "yyyymmddhh") & "*.csv") <> "" And _
Dir(stpDir & stpPrefix & "Stockport_" & Format(reportDateTime, "yyyymmddhh") & "*.csv") <> "" And _
Dir(stpDir & stpPrefix & "Oldbury_" & Format(reportDateTime, "yyyymmddhh") & "*.csv") <> "" And _
Dir(stpDir & stpPrefix & "Leicester_" & Format(reportDateTime, "yyyymmddhh") & "*.csv") <> "" And _
Dir(feedsDir & duplicatePrefix & Format(reportDateTime, "yyyymmdd_hh00") & ".txt") <> "" And _
Dir(feedsDir & unmasteredprefix & Format(reportDateTime, "yyyymmdd") & ".txt") <> "" And _
Dir(feedsDir & unpinnedPrefix & Format(reportDateTime, "yyyymmdd") & ".txt") <> "" And _
Dir(feedsDir & mismatchPrefix & Format(reportDateTime, "yyyymmdd_hh00") & ".txt") <> "" Then
cmbReportDateTime.AddItem Format(reportDateTime, "ddd dd-mmm-yy hh00")
ThisWorkbook.Worksheets("Lookups").Range("Z" & ii).Value = Format(reportDateTime, "ddd dd-mmm-yy hh00")
ii = ii + 1
ElseIf Dir(r04Dir & "Archive\" & r04Prefix & 1 & "_GAS_*" & UCase(Format(reportDateTime, "dd_mmm_yyyy_hh")) & "*.csv") <> "" And _
Dir(r04Dir & "Archive\" & r04Prefix & 2 & "_GAS_*" & UCase(Format(reportDateTime, "dd_mmm_yyyy_hh")) & "*.csv") <> "" And _
Dir(r04Dir & "Archive\" & r04Prefix & 3 & "_GAS_*" & UCase(Format(reportDateTime, "dd_mmm_yyyy_hh")) & "*.csv") <> "" And _
Dir(r04Dir & "Archive\" & r04Prefix & 4 & "_GAS_*" & UCase(Format(reportDateTime, "dd_mmm_yyyy_hh")) & "*.csv") <> "" And _
Dir(r04Dir & "Archive\" & r04Prefix & 5 & "_GAS_*" & UCase(Format(reportDateTime, "dd_mmm_yyyy_hh")) & "*.csv") <> "" And _
Dir(r04Dir & "Archive\" & r04Prefix & 6 & "_GAS_*" & UCase(Format(reportDateTime, "dd_mmm_yyyy_hh")) & "*.csv") <> "" And _
Dir(r04Dir & "Archive\" & r04Prefix & 7 & "_GAS_*" & UCase(Format(reportDateTime, "dd_mmm_yyyy_hh")) & "*.csv") <> "" And _
Dir(stpDir & stpPrefix & "Uddingston_" & Format(reportDateTime, "yyyymmddhh") & "*.csv") <> "" And _
Dir(stpDir & stpPrefix & "Stockport_" & Format(reportDateTime, "yyyymmddhh") & "*.csv") <> "" And _
Dir(stpDir & stpPrefix & "Oldbury_" & Format(reportDateTime, "yyyymmddhh") & "*.csv") <> "" And _
Dir(stpDir & stpPrefix & "Leicester_" & Format(reportDateTime, "yyyymmddhh") & "*.csv") <> "" And _
Dir(feedsDir & "archive\" & duplicatePrefix & Format(reportDateTime, "yyyymmdd_hh00") & ".txt") <> "" And _
Dir(feedsDir & "archive\" & unmasteredprefix & Format(reportDateTime, "yyyymmdd") & ".txt") <> "" And _
Dir(feedsDir & "archive\" & unpinnedPrefix & Format(reportDateTime, "yyyymmdd") & ".txt") <> "" And _
Dir(feedsDir & "archive\" & mismatchPrefix & Format(reportDateTime, "yyyymmdd_hh00") & ".txt") <> "" Then
cmbReportDateTime.AddItem Format(reportDateTime, "ddd dd-mmm-yy hh00") & " (archive)"
ThisWorkbook.Worksheets("Lookups").Range("Z" & ii).Value = Format(reportDateTime, "ddd dd-mmm-yy hh00")
ii = ii + 1
End If
reportDateTime = reportDateTime - 1/24
Wend
Application.StatusBar = "Search Complete!"
End Sub
Hallo Doug, ich versuchte 'Debug.Print Me.cmbReportDateTime.ListIndex = 0', um zu sehen, was der Wert zurückgeben würde und es sagt" Falsch " – Tabias
Nur so bin ich klar - nach dem Lesen meiner Post habe ich nicht gedacht es ergab Sinn. Ich möchte nicht, dass das Kombinationsfeld den ersten Eintrag anzeigt, ich möchte nur den Wert des ersten Eintrags abrufen, während das Feld selbst für den Benutzer leer bleibt, bis der Benutzer selbst einen Wert auswählt. – Tabias
Nun, der erste Wert einer Combobox ist immer Null. ein leerer Abschnitt ist -1 und so weiter und so weiter –