getting macro to run

G

Guest

hi,

i picked this up last week on this forum and have not been able to get it to
run. i can't get it to show up in the run macro dialog. does anyone have
sugestions as to how i can get this snippet to run? thanks--

Private Sub User(ByVal Target As Range)
Target.Interior.ColorIndex = 0
On Error Resume Next
Dim curComment As String
curComment = ""
curComment = Target.Comment.Text
If curComment <> "" Then curComment = curComment & Chr(10)
Target.AddComment
Target.Comment.Text Text:=curComment & _
ActiveWorkbook.Application.UserName & _
Chr(10) & " Rev. " & Format(Date, "yyyy-mm-dd ") & _
Format(Time, "hh:mm")
ActiveCell.Comment.Visible = False
'comment perhaps should be resized
End Sub
 
B

Bob Phillips

It won't show for two reasons, it is Private, and it has arguments.

Maybe this is what you want

Sub User()
Dim curComment As String
With ActiveCell

.Interior.ColorIndex = 0
On Error Resume Next
curComment = ""
curComment = .Comment.Text
If curComment <> "" Then curComment = curComment & Chr(10)
.AddComment
.Comment.Text Text:=curComment & _
ActiveWorkbook.Application.UserName & _
Chr(10) & " Rev. " & Format(Date, "yyyy-mm-dd ") & _
Format(Time, "hh:mm")
End With
End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
G

Guest

I pasted your sub in a standard module.

I also pasted:

Sub demo()
Call User(ActiveCell)
End Sub

in the same standard module.

back on the worksheet, I entered a comment in a cell, selected that cell and
ran the macro demo

The macro ran successfully and modified the comment to include my name and a
time/date marker.
 

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

Similar Threads

Undo doesn't work! 4
Note Code Help 1
referenced file 1
Cell Change to Comment 2
VBA to edit a comment 3
Clear Comment problem 2
Dates in Excel 2003 1
time in subject line 1

Top