Share via

Accessing the Excel function TODAY() ...

Anonymous
2021-10-27T14:31:14+00:00

Hi,

I'm trying to use an Excel function called TODAY(). I wish to use it simple macro but it doesn't appear to be working. Here is my example:

Sub Test_Display_My_Date()

MsgBox Text(TODAY(), "mm, " - " dd, " - " yy")

End Sub

This macro returns a compile error: "Sub or Function not defined". Can someone explain what I am doing wrong?

Thanks,
Greg

Microsoft 365 and Office | Excel | For education | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

2 answers

Sort by: Most helpful
  1. Anonymous
    2021-10-27T15:31:57+00:00

    Thank you! This is just what I needed! :-)

    Was this answer helpful?

    0 comments No comments
  2. HansV 462.6K Reputation points
    2021-10-27T14:46:33+00:00

    TODAY() is an Excel worksheet function, but not a VBA function. The VBA equivalent is Date.

    Similarly, TEXT is Excel only. The VBA equivalent is Format.

    Sub Test_Display_My_Date()
    MsgBox Format(Date, "mm - dd - yy")
    End Sub

    Was this answer helpful?

    0 comments No comments