How to add date to cell with a button

Occasional Visitor

Hello, I want to add the date at the end of a line with a button. It's to follow how many time our product are cleanned. I want to have on a line : the product name, a button and all the date of cleanning. And when you click at the button, the date add at the end of the line

 

Sorry for my bad english. 

Thanks in advance

ReeducBenodet

1 Reply

@ReeducBenodet 

Here is an elegant approach to solving the problem without any button :).

Example in the included file.

Enter the right mouse button in the area A1:B10 and the date appears, pressing it again disappears the date.

 

VBA Code:

 

 

Option Explicit

Private Sub Worksheet_BeforeRightClick(ByVal Target As Excel.Range, Cancel As Boolean)
'Me.Unprotect ("1234")
    If Not Intersect(Target, Range("A1:B10")) Is Nothing Then
        Target = IIf(Target = "", Date, "")
        Cancel = True
    End If
    'Me.Protect ("1234")
End Sub

 

 

 

Hope I was able to help you with this approach :).

 

NikolinoDE

I know I don't know anything (Socrates)