VBA Updating Comments to Active Cell

gswann

New Member
Joined
Dec 14, 2018
Messages
5
Hi Everyone,

I'm looking to try and solve a problem with a calendar that's been created by the business. It's a crude way of our board being able to know when meetings are taking place throughout the year, it's built in excel rather than just using outlook but it's what they've decided.

There's a tab per month with 5 rows per day within that month. Each row has a validated list of meeting names, what i'm trying to do is get VBA add a comment to the cell once it's been updated with a meeting type.

The problem I've been experiencing is that when adding the comments it's also overwriting any existing comments as well or adding comments to existing meetings that have been added that don't have a comment.

What i'm looking to put together is almost like a check list, so once the cell becomes active, if the cell is blank, do nothing, once active and it's not blank and doesn't have a comment, do nothing, but once active and the user has just entered something from the drop down menu add the comment of application.username and the date and time.

He's what I've cobbled together so far.

Private Sub Worksheet_Change(ByVal Target As Range)
If ActiveCell = "" Then
Exit Sub
End If



If Not IsEmpty(ActiveCell) Then
Else
With ActiveCell
.AddComment
.Comment.Text Text:=Application.UserName & Chr(10) & "Updated " & Now()
.Comment.Shape.TextFrame.AutoSize = True
End With
Exit Sub
End If

End Sub

Any help on this is greatly appreciated.

Thanks
Gary
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
Try this

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Count > 1 Then Exit Sub
    If Target.Value = "" Then Exit Sub
    With Target
        If .Comment Is Nothing Then
            .AddComment
            .Comment.Text Text:=Application.UserName & Chr(10) & "Updated " & Now()
            .Comment.Shape.TextFrame.AutoSize = True
        End If
    End With
End Sub
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

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