ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   formula in code (https://www.excelbanter.com/excel-programming/411301-formula-code.html)

geebee

formula in code
 
hi,

i have the following:

Dim CurrentReportMonth As Date
CurrentReportMonth = "=DATE(YEAR(NOW()),MONTH(NOW())-1+0,1)"

i am trying to figure out how i can make this work, like setting the
currentreportmonth in code, but i keep getting the error message. what am i
doing wrong?

thanks in advance,
geebee


Bob Phillips

formula in code
 

Dim CurrentReportMonth As Date
CurrentReportMonth = DateSerial(Year(Date),Month(Date)-1,1)


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"geebee" (noSPAMs) wrote in message
...
hi,

i have the following:

Dim CurrentReportMonth As Date
CurrentReportMonth = "=DATE(YEAR(NOW()),MONTH(NOW())-1+0,1)"

i am trying to figure out how i can make this work, like setting the
currentreportmonth in code, but i keep getting the error message. what am
i
doing wrong?

thanks in advance,
geebee




Gary''s Student

formula in code
 
Sub gibbs()
Dim CurrentReportMonth As Date
CurrentReportMonth = Evaluate("DATE(YEAR(NOW()),MONTH(NOW())-1+0,1)")
MsgBox (CurrentReportMonth)
End Sub

--
Gary''s Student - gsnu200787


All times are GMT +1. The time now is 08:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com