<span style=
"color: rgb(51, 51, 51); font-family: Tahoma, Verdana, Arial, sans-serif; font-size: 14px; background-color: rgb(239, 239, 239);"
>Hallo an alle,</span>
<span style=
"color: rgb(51, 51, 51); font-family: Tahoma, Verdana, Arial, sans-serif; font-size: 14px; background-color: rgb(239, 239, 239);"
>habe eine Userform mit folgendem Code:</span>
Private
Sub
ListBox1_Click()
Dim
pfadPDF
As
String
Dim
lZeile
As
Long
TextBox1 =
""
TextBox2 =
""
TextBox3 =
""
TextBox4 =
""
TextBox5 =
""
TextBox6 =
""
TextBox7 =
""
TextBox8 =
""
lZeile = 2
Do
While
Trim(
CStr
(Tabelle6.Cells(lZeile, 2).Value)) <>
""
If
ListBox1.Text = Trim(
CStr
(Tabelle6.Cells(lZeile, 2).Value))
Then
TextBox1 = Trim(
CStr
(Tabelle6.Cells(lZeile, 1).Value))
TextBox2 =
"Nr_"
& Tabelle6.Cells(lZeile, 2).Value
TextBox3 = Tabelle6.Cells(lZeile, 3).Value
TextBox4 = Tabelle6.Cells(lZeile, 4).Value
TextBox5 = Tabelle6.Cells(lZeile, 5).Value
TextBox6 = Tabelle6.Cells(lZeile, 6).Value
TextBox7 = Format(Tabelle6.Cells(lZeile, 7).Value,
"Currency"
)
TextBox7.BackColor = Tabelle6.Cells(lZeile, 12).DisplayFormat.Interior.Color
TextBox8 = Tabelle6.Cells(lZeile, 9).Value
Exit
Do
End
If
lZeile = lZeile + 1
Loop
pfadPDF = Worksheets(
"Konfiguration"
).Range(
"C3"
).Value
Dim
MyObj
As
Object
, MySource
As
Object
, file
As
Variant
file = Dir(pfadPDF)
While
(file <>
""
)
If
InStr(file, UserForm2.TextBox2)
Then
UserForm2.TextBox9.Value = pfadPDF & file
Exit
Sub
End
If
file = Dir
Wend
End
Sub
Code:
Private
Sub
UserForm_Initialize()
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> </span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
>
Dim
lZeile
As
Long
</span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> </span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> TextBox1 =
""
</span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> TextBox2 =
""
</span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> TextBox3 =
""
</span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> TextBox4 =
""
</span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> TextBox5 =
""
</span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> TextBox6 =
""
</span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> TextBox7 =
""
</span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> TextBox8 =
""
</span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> </span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> ListBox1.Clear
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> </span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> lZeile = 2
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
>
Do
While
Trim(
CStr
(Tabelle6.Cells(lZeile, 2).Value)) <>
""
</span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> </span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> ListBox1.AddItem Trim(
CStr
(Tabelle6.Cells(lZeile, 2).Value))</span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> lZeile = lZeile + 1
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
> </span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
>
Loop
</span>
<span style=
"color: rgb(51, 51, 51); font-family: Monaco, Consolas, Courier, monospace; font-size: 13px;"
>
End
Sub
</span>Funktioniert soweit recht gut, nur möchte ich in der Listbox1 nicht alle Einträge von Spalte 1 haben, sondern sie an ein Bedingung knüpfn, z.B., wenn Tabelle6.Cells(lZeile, 11).Value =
""
oder wenn Tabelle6.Cells(lZeile, 12).Value ist rot markiert.