AW: VBA sverweis
01.09.2013 22:46:40
Bastian
Hallo Alex,
hab den Code entsprechend erweitert. Kommt mit einem Label aus, welches Du entsprechend größer ziehst.
Die einzelnen Strings stehen dann mit einem Zeilenumbruch alle in Label1:
Private Sub CommandButton1_Click()
Dim a As Variant
Dim zeile As Long
Dim intZaehler As Integer
Dim intZaehler2 As Integer
Dim caption() As String
Dim strCaption As String
zeile = Worksheets("Datentabelle").Cells(Rows.Count, 1).SpecialCells(xlLastCell).Row
If txtNr.Value "" Then
a = Application.Match(txtNr * 1, Worksheets("Datentabelle").Columns(1), 0)
If IsNumeric(a) Then
For intZaehler = a To zeile
Debug.Print Worksheets("Datentabelle").Cells(intZaehler, 1).Value
If IsEmpty(Worksheets("Datentabelle").Cells(intZaehler, 1).Value) Then Exit For
If Mid(Worksheets("Datentabelle").Cells(intZaehler, 1).Value, 1, 4) = txtNr.Value _
Then
ReDim Preserve caption(0 To intZaehler2)
caption(intZaehler2) = Worksheets("Datentabelle").Cells(intZaehler, 2).Value
End If
intZaehler2 = intZaehler2 + 1
Next intZaehler
strCaption = Join(caption, Chr(13))
Label1.caption = strCaption
Else
MsgBox "Nr. nicht vorhanden"
End If
Else
End If
End Sub
Gruß, Bastian