Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
1256to1260
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 mit Zelleninhalt befüllen

Kommentar mit Zelleninhalt befüllen
Basti
Hallo Zusammen,
Ich möchte mein Makro, dass dank der Hilfe des Forums bestens funkioniert, weiter anpassen und benötigte dazu etwas Hilfe.
Da ich die Kommentare als Änderungshistorie verwenden möchte würde ich gerne wissen, wie der Code aussehen müsste, damit in der ersten Zeile des Kommentars mein Name, das aktuelle Datum und der aktuellen Zellinhalt geschrieben wird. Die zweite Zeile soll dann Name, Datum und neuen Kommentar enthalten.
Danke und Gruß
Basti
Sub CommentInsert()
' CommentInsert
' Tastenkombination: Strg+Umschalt+X
Dim rngCell As Range
Dim rngStart As Range
Dim ws As Worksheet
Dim com As Comment
Dim sCom As String
Application.ScreenUpdating = False
On Error Resume Next
sCom = InputBox( _
prompt:="Bitte Kommentar eingeben:")
With ActiveCell
.DeleteComment
.AddComment
.Comment.Visible = True
.Comment.Text _
Text:="Name" & " " & Date & ":" & " " & sCom
End With
If Selection.Cells.Count > 1 Then
Set rngStart = Selection.Cells(1)
Else
Set rngStart = Selection
End If
For Each rngCell In rngStart.SpecialCells(xlCellTypeComments)
rngCell.Comment.Shape.TextFrame.AutoSize = True
With rngCell.Comment
.Shape.Top = .Parent.Top - 10
.Shape.Left = .Parent.Offset(0, 1).Left + 10
End With
Next
For Each ws In ActiveWorkbook.Worksheets
For Each com In ws.Comments
If com Is Nothing Then
MsgBox "Es ist kein Kommentar vorhanden."
Else
With com.Shape
With .Fill
.ForeColor.SchemeColor = 1
.Visible = msoTrue
.Transparency = False
End With
.Line.ForeColor.SchemeColor = 0
With .TextFrame
.Orientation = 1
.VerticalAlignment = xlBottom
.AutoSize = True
With .Characters.Font
.Name = "tahoma"
.Size = 12
.ColorIndex = 1
.Bold = False
End With
End With
End With
End If
Next com
Next ws
Set rngStart = Nothing
Application.ScreenUpdating = True
End Sub

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

Betreff
Benutzer
Anzeige
AW: Kommentar mit Zelleninhalt befüllen
23.03.2012 09:59:32
hary
Hallo Basti
ersetz mal:

With ActiveCell
.DeleteComment
.AddComment
.Comment.Visible = True
.Comment.Text _
Text:="Name" & " " & Date & ":" & " " & sCom
End With

durch:

With ActiveCell
If Not .Comment Is Nothing Then
.Comment.Text Text:=.Comment.Text & Chr(10) & Environ("UserName") & " " & Date & " " & . _
Value
Else
.AddComment
.Comment.Text Text:=Environ("UserName") & " " & Date & " " & .Value
End If
End With

gruss hary
AW: Kommentar mit Zelleninhalt befüllen
24.03.2012 08:31:35
Basti
Servus Hary,
Danke für deine Hilfe.
Der Code funktioniert und ich werde mal ein bisschen damit spielen.
Gruß Basti
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige