Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Anzeige
Inhaltsverzeichnis

UF-Listbox einlesen

Forumthread: UF-Listbox einlesen

UF-Listbox einlesen
15.05.2015 23:18:08
ludmila
Hallo Experten,
ich lese eine UF-Listbox mit nachfolgendem Code ein.
Problem ist nur, wenn kein kein Eintrag vorhanden ist, bekomme ich eine Fehlermeldung
Laufzeitfehler 380, Cuolumneigenschaft kann nicht gesetzt werden.
Wie kann ich das umgehen?
Danke
Gruß, Ludmila
Sub KD_lst_Bank_Einlesen()
Dim bytBankSpalte As Byte
Dim bytBankSpalte1 As Byte
Dim ii as Integer
Dim iRowU As Integer
Dim arr()
Set WkbD = Workbooks(sData)
Set WksBank = WkbD.Worksheets(Bank)
frmKD.lstBank.Clear
With WksBank
bytBankSpalte = .Rows(1).Find(what:="DB_KD_BANK_NR", LookIn:=xlValues, lookat:= _
xlWhole).Column
For ii = 2 To .Cells(Rows.Count, 1).End(xlUp).Row
If Not IsEmpty(.Cells(ii, 1)) And .Cells(ii, bytBankSpalte) = frmKD.lblKDNr.Caption  _
Then
ReDim Preserve arr(0 To 5, 0 To iRowU)
bytBankSpalte1 = .Rows(1).Find(what:="DB_KD_BANK_INHABER", LookIn:=xlValues, lookat: _
=xlWhole).Column
arr(0, iRowU) = .Cells(ii, bytBankSpalte1)
bytBankSpalte1 = .Rows(1).Find(what:="DB_KD_BANKNAME", LookIn:=xlValues, lookat:= _
xlWhole).Column
arr(1, iRowU) = .Cells(ii, bytBankSpalte1)
bytBankSpalte1 = .Rows(1).Find(what:="DB_KD_BANK_KOMPLETT_IBAN", LookIn:=xlValues,  _
lookat:=xlWhole).Column
arr(2, iRowU) = .Cells(ii, bytBankSpalte1)
bytBankSpalte1 = .Rows(1).Find(what:="DB_KD_BANK_BIC", LookIn:=xlValues, lookat:= _
xlWhole).Column
arr(3, iRowU) = .Cells(ii, bytBankSpalte1)
bytBankSpalte1 = .Rows(1).Find(what:="DB_KD_ID_BANK", LookIn:=xlValues, lookat:= _
xlWhole).Column
arr(4, iRowU) = .Cells(ii, bytBankSpalte1)
arr(5, iRowU) = " "
iRowU = iRowU + 1
End If
Next ii
End With
With frmKD
.lstBank.ColumnWidths = 140 & ";" & 140 & ";" & 140 & ";" & 117 & ";" & 0
.lstBank.Column = arr
.lblBankDClick.Caption = "Doppelklick öffnet Bearbeitung - Gesamt:" & " " & .lstBank. _
ListCount
End With
1 End Sub

Anzeige

2
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: UF-Listbox einlesen
15.05.2015 23:27:52
Nepumuk
Hallo,
so:
With frmKD
    .lstBank.ColumnWidths = 140 & ";" & 140 & ";" & 140 & ";" & 117 & ";" & 0
    If SafeArrayGetDim(arr) <> 0 Then .lstBank.Column = arr
    .lblBankDClick.Caption = "Doppelklick öffnet Bearbeitung - Gesamt:" & " " & .lstBank.ListCount
End With

Ganz oben im Modul folgende Importfunktion:
Private Declare PtrSafe Function SafeArrayGetDim Lib "oleaut32.dll" ( _
    ByRef pArray() As Any) As Long

Gruß
Nepumuk

Anzeige
AW: UF-Listbox einlesen
15.05.2015 23:50:01
ludmila
Hallo Nepumuk,
und wie soll da eine "Normal- Sterbliche" darauf kommen?
Vielen Dank, für Deine Hilfe!
Gruß
Ludmila
Anzeige
Anzeige
Live-Forum - Die aktuellen Beiträge
Datum
Titel
14.05.2026 13:31:09
14.05.2026 09:50:42
13.05.2026 19:14:18