Inserting dates into comments automatically problem

akaj321akaj

New Member
Joined
May 23, 2011
Messages
11
First off here is the code im using for this

HTML:
Private Sub worksheet_change(ByVal Target As Range)
     'This sub is to  record cell  changes and use corresponding cells to record  date time, user id and pc id.
    If Target.Cells.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("A2:ae3000")) Is Nothing Then
        Target.AddComment.Text Now & FindNetUserName & "  " & FindComputerName
    End If
    If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub
     'this sub forces all text into uppercase
    On Error Resume Next
    Application.EnableEvents = False
    Target = UCase(Target)
    Application.EnableEvents = True
    On Error GoTo 0
End Sub
What it does is it inserts a comment with the current date onto the cell that i just edited.
The problem im having with it is that whenever i goto edit the box that i just did it comes up with a error and doesnt work.
Im trying to make it to where i can delete the selected cell and it will also delete the comment, allowing me to enter a new value and it also add a new comment without crashing?
Any ideas on what i can do to make this work? its greatly appreciated!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Hi,

Maybe, instead of Now try CStr(Now)

I'm assuming that FindUserName and FindComputerName are defined and working ok.

M.
 
Upvote 0
Try:
Rich (BB code):
Private Sub worksheet_change(ByVal Target As Range)
     'This sub is to  record cell  changes and use corresponding cells to record  date time, user id and pc id.
    If Target.Cells.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("A2:ae3000")) Is Nothing Then
        Target.ClearComments
        Target.AddComment.Text Now & FindNetUserName & "  " & FindComputerName
    End If
    If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub
     'this sub forces all text into uppercase
    On Error Resume Next
    Application.EnableEvents = False
    Target = UCase(Target)
    Application.EnableEvents = True
    On Error GoTo 0
End Sub
 
Upvote 0
And if you want the cell to contain no comment if it is blank then:
Rich (BB code):
Private Sub worksheet_change(ByVal Target As Range)
     'This sub is to  record cell  changes and use corresponding cells to record  date time, user id and pc id.
    If Target.Cells.Count > 1 Then Exit Sub
    If Not Intersect(Target, Range("A2:ae3000")) Is Nothing Then
        Target.ClearComments
        If Len(Target.Value) > 0 Then Target.AddComment.Text Now & FindNetUserName & "  " & FindComputerName
    End If
    If Target.Cells.Count > 1 Or Target.HasFormula Then Exit Sub
     'this sub forces all text into uppercase
    On Error Resume Next
    Application.EnableEvents = False
    Target = UCase(Target)
    Application.EnableEvents = True
    On Error GoTo 0
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,551
Members
452,927
Latest member
rows and columns

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top