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