small debug help required

  • Thread starter Thread starter Mathew P Bennett
  • Start date 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
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top