small debug help required

  • Thread starter Mathew P Bennett
  • Start date
M

Mathew P Bennett

Good Evening All,

I was yesterday sent some simple code from here yesterday,
(cheers Jim), however I am a newcomer to code,
and cannot correct it, with my limited knowledge.
Error in line 3

Private Sub CommandButton1_Click()
'Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("datecell").Address Then
If LCase(Target.Value) = "today" Then
Target.Value = Format(Now, "dd/mm/yy")
End If
End If
End Sub


Any help, as usual most appreciated.
Cheers,
Mathew
 
G

Gromit

Do you want the macro to run when you click the button or when the cell
value changes? You seem to have a mix of both here.

Graham
 
G

Gromit

If it's the button version you want, try this:

Private Sub CommandButton1_Click()

If LCase([datecell].Value) = "today" Then
[datecell].Value = Format(Now, "dd/mm/yy")
End If

End Sub
 
Top