Excel VBA IF statement

Hewlett-packard / X
October 19, 2010 at 03:47:59
Specs: Win 2003, 512
Hi,

I have a macro that saves my file with a name and current date, see below -

fileSaveName = "Order Data " & Format(Now(), "dd.mmm.yyyy") & ".xls"

I want to amend this so that the file will save it as, for example -

fileSaveName = IF(MONTH(NOW())=4,"Q1",IF(MONTH(NOW())=7,"Q2",IF(MONTH(NOW())=10,"Q3","Q4"))) & Format(Now(), "dd.mmm.yyyy") & ".xls"


but I am unsure of the correct syntax.

Thanks,
Kasey


See More: Excel VBA IF statement

Report •


#1
October 19, 2010 at 07:14:25
Well, it'd depend on exactly where you define the start of your quarters, but I imagine it'd look something like this:
"Q" & Int((Month(Now) - 1) / 3) + 1 & "." & Format(Now(), "dd.mmm.yyyy") & ".xls"

How To Ask Questions The Smart Way


Report •
Related Solutions


Ask Question