Live-Forum - Die aktuellen Beiträge
Datum
Titel
24.04.2024 19:29:30
24.04.2024 18:49:56
Anzeige
Archiv - Navigation
1748to1752
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Inhaltsverzeichnis

Kommentar per MsgBox / Abbruch

Kommentar per MsgBox / Abbruch
26.03.2020 09:02:54
Sven
Guten Morgen,
folgenden Code habe ich mir zusammen gebastelt. Wenn ich in der MsgBox auf Abbrechen klicke, dann schreibt er das aktuelle Datum in die Zelle sowie in den Kommentar.
Frage: wie muss ich den Code umschreiben, dass er tatsächlich abbricht?
Danke im voraus!
Sub Kommentar()
Dim strComment As String
With ActiveCell
If .Comment Is Nothing Then
strComment = InputBox("Please add your comment.", "History")
.AddComment
With .Comment
.Text Text:=Date & " " & strComment
.Shape.TextFrame.AutoSize = True
ActiveCell = Date & " " & strComment
End With
Else
strComment = InputBox("Please add your commentn.", "Complete History")
.Comment.Text Text:=.Comment.Text & vbLf & Date & " " & strComment
ActiveCell = Date & " " & strComment
End If
End With
End Sub

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

Betreff
Datum
Anwender
Anzeige
AW: Kommentar per MsgBox / Abbruch
26.03.2020 09:58:40
ChrisL
Hi Sven
Hier ein Muster. "Application.InputBox" verwenden.
Sub t()
Dim varAntwort As Variant
varAntwort = Application.InputBox("Test")
If varAntwort = False Then
MsgBox "Abbruch"
Exit Sub
ElseIf varAntwort = "" Then
MsgBox "keine Eingabe"
Exit Sub
Else
MsgBox "mach weiter"
End If
End Sub
cu
Chris
AW: Kommentar per MsgBox / Abbruch
26.03.2020 11:07:31
Sven
Vielen Dank!
Vielleicht gibt es elegantere Methoden, aber es funktioniert. Klasse!
Sub Kommentar()
Dim varAntwort As Variant
Dim strComment As String
varAntwort = Application.InputBox("Please add your comment.", "Complete History")
If varAntwort = False Then
Exit Sub
ElseIf varAntwort = "" Then
Exit Sub
Else
With ActiveCell
If .Comment Is Nothing Then
strComment = varAntwort
.AddComment
With .Comment
.Text Text:=Date & " " & strComment
.Shape.TextFrame.AutoSize = True
ActiveCell = Date & " " & strComment
End With
Else
strComment = varAntwort
.Comment.Text Text:=.Comment.Text & vbLf & Date & " " & strComment
ActiveCell = Date & " " & strComment
End If
End With
End If
End Sub

Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige