Now Function Question
I'm trying to use the Now function in VBA. I continue to get a compile
error: Expected function or variable. The error highlights on the
word,
Now.
The formula below is an example of the code.
Sub Dateparttest()
Dim today
today = Month(Now)
Range("b1").Value = today
End Sub
Although I am not sure why VBA cares about it, the variable name "today"
is
where your problem is. I'm guessing it is a reserved keyword for VBA
inside
of Excel... change the variable name and your code should work fine
(unless
you stumble upon another keyword, that is<g).
Rick
Today is an Excel function.
I realize that at the spreadsheet level, but Today does not seem to be
"defined" within the VBA world itself.
Rick
|