Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 190
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using formula in code Alan M Excel Programming 1 August 17th 07 02:09 AM
formula or vba code Nader Excel Programming 3 August 15th 06 03:11 PM
Help with Formula in Code JMB Excel Programming 0 March 26th 06 11:48 PM
Add formula in the code Annette[_5_] Excel Programming 3 February 21st 05 08:19 PM
formula to code help JohnE Excel Programming 2 February 28th 04 01:27 AM


All times are GMT +1. The time now is 06:35 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"