NewComment

J

Jeff Mackeny

I have the flllowing code to add a new comment, can anyone help me add a
line so it would add the date on the comment

Sub NewComment2()

Dim strComment As String

strComment = InputBox("EnterNote: ", "Note.")

If Len(Trim(strComment)) = "" Then Exit Sub


With ActiveCell
.ClearComments
.AddComment
.Comment.Visible = False
With .Comment.Shape.TextFrame
.Characters.Text = strComment
.Characters.Font.Name = "Comic Sans MS"
.Characters.Font.Bold = True
.Characters.Font.Italic = False
.Characters.Font.Size = 11
'or even certain Characters'
.Characters(14, 4).Font.Bold = False
.Characters(1, 3).Font.ColorIndex = 0
.AutoSize = True
End With
End With

End Sub
 
F

Frank Kabel

Hi Jeff
change the line
If Len(Trim(strComment)) = "" Then Exit Sub

to
If Len(Trim(strComment)) = "" Then
Exit Sub
else
strComment = "Date: " & Format(Date,"MM/DD/YYYY") & _
vbcr & Trim(strComment)
end if
 
J

Jeff Mackeny

Frank,

When running it it says error compling 'Else without IF' , it now looks like
this

Dim strComment As String

strComment = InputBox("EnterNote: ", "Note.")

If Len(Trim(strComment)) = "" Then Exit Sub

Else
strComment = "Date: " & Format(Date, "MM/DD/YYYY") & _
vbCr & Trim(strComment)
End If


With ActiveCell
.ClearComments
.AddComment
.Comment.Visible = False
With .Comment.Shape.TextFrame
.Characters.Text = strComment
.Characters.Font.Name = "Comic Sans MS"
.Characters.Font.Bold = True
.Characters.Font.Italic = False
.Characters.Font.Size = 11
'or even certain Characters'
.Characters(14, 4).Font.Bold = False
.Characters(1, 3).Font.ColorIndex = 0
.AutoSize = True
End With
End With

End Sub
 
J

Jeff Mackeny

never mind it works.

thanks

Jeff Mackeny said:
Frank,

When running it it says error compling 'Else without IF' , it now looks like
this

Dim strComment As String

strComment = InputBox("EnterNote: ", "Note.")

If Len(Trim(strComment)) = "" Then Exit Sub

Else
strComment = "Date: " & Format(Date, "MM/DD/YYYY") & _
vbCr & Trim(strComment)
End If


With ActiveCell
.ClearComments
.AddComment
.Comment.Visible = False
With .Comment.Shape.TextFrame
.Characters.Text = strComment
.Characters.Font.Name = "Comic Sans MS"
.Characters.Font.Bold = True
.Characters.Font.Italic = False
.Characters.Font.Size = 11
'or even certain Characters'
.Characters(14, 4).Font.Bold = False
.Characters(1, 3).Font.ColorIndex = 0
.AutoSize = True
End With
End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top