Subtracting The Today's Date From Cell Date And Viewing
Result In Cell Comment
In this study, we have used the same template again. When the button on userform is clicked , today's date is subtracted from the date in cell. Result can be viewed on the added comment in cell.
Example : 20.10.2017 - 21.09.2016 (Today's date) = 394 days
Example : 20.10.2017 - 21.09.2016 (Today's date) = 394 days
VBA codes to add comment :
Private Sub CommandButton1_Click() 'Comments are added
Application.ScreenUpdating = False
CommandButton2_Click 'To delete If cell has comment
On Error Resume Next
For Each cell In Sheets("liste").Range("A2:A" & Cells(Rows.Count, 1).End(xlUp).Row)
cell.AddComment
cell.Comment.Visible = True
cell.Comment.Shape.Select
cell.Comment.Shape.TextFrame.AutoSize = True
cell.Comment.Text Text:=CStr(DateDiff("d", Date, cell.Value))
Next
Call create_comment_shape
Application.ScreenUpdating = True
Range("A1").Activate
End Sub
Application.ScreenUpdating = False
CommandButton2_Click 'To delete If cell has comment
On Error Resume Next
For Each cell In Sheets("liste").Range("A2:A" & Cells(Rows.Count, 1).End(xlUp).Row)
cell.AddComment
cell.Comment.Visible = True
cell.Comment.Shape.Select
cell.Comment.Shape.TextFrame.AutoSize = True
cell.Comment.Text Text:=CStr(DateDiff("d", Date, cell.Value))
Next
Call create_comment_shape
Application.ScreenUpdating = True
Range("A1").Activate
End Sub
Read more ...