ich möchte Termine in einer Msgbox angezeigt bekommen.
Leider kommt beim Auslesen im nach dem Text "Termin" eine oder 2 Nullen.
Wie kann ich das vermeiden?
Danke!
Gruß
Sigi
https://www.herber.de/bbs/user/123965.xlsm
Option Explicit
Private Sub CommandButton1_Click()
Dim Datum As Variant
Dim lol As Long
Dim si As Single
Dim Termin As String
Datum = Cells(1, 8)
For lol = 2 To Cells(Rows.Count, 2).End(xlUp).Row
If Cells(lol, 2) = Datum Then
Termin = Termin & vbLf & "von " & Format(Cells(lol, 3), "hh:mm") & " bis " & Format( _
Cells(lol, 4), "hh:mm")
si = si + 1
Else
End If
Next
Select Case si
Case 1
MsgBox "Sie haben heute " & Datum & vbLf & si & " Termin " & vbLf & Termin
Cells(9, 7) = "Sie haben heute " & Datum & vbLf & si & " Termin " & Termin
Case Is > 1
MsgBox "Sie haben heute " & Datum & vbLf & si & " Termine " & vbLf & Termin
Cells(9, 7) = "Sie haben heute " & Datum & vbLf & si & " Termine " & Termin
End Select
End Sub
Gruß WernerPrivate Sub CommandButton1_Click()
Dim Datum As Variant
Dim lol As Long
Dim si As Single
Dim Termin As String
si = 0
Termin = "" 'oder diese Zeile löschen
Datum = Cells(1, 8)
For lol = 2 To Cells(Rows.Count, 2).End(xlUp).Row
If Cells(lol, 2) = Datum Then
Termin = Termin & vbLf & "von " & Format(Cells(lol, 3), "hh:mm") & " bis " & Format( _
Cells(lol, 4), "hh:mm")
si = si + 1
Else
End If
Next
Select Case si
Case 1
MsgBox "Sie haben heute " & Datum & vbLf & "einen Termin " & Termin
' Cells(9, 7) = "Sie haben heute " & Datum & vbLf & "einen Termin " & Termin
Case Is > 1
MsgBox "Sie haben heute " & Datum & vbLf & si & " Termine " & Termin
' Cells(9, 7) = "Sie haben heute " & Datum & vbLf & "Termine " & Termin
End Select
End Sub