check if is last day of month then, else

P

pswanie

i got a macro to copy and special paste data in order to get a accumalative
sales data. i want to add to it so that it check if today is the last day of
the month.

something like

if now() = lastday of month then
run macro
else
range a1.value = ""
end if


thanx
Phillip
 
R

Ron Coderre

Try this:

If Date = dateserial(year(date),Month(date)+1,0) then
'do something
Else
'do something else
End If


Is that something you can work with?
--------------------------

Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)
 
R

Rick Rothstein \(MVP - VB\)

The following is probably what you want...

If Date= DateSerial(Year(Date), Month(Date) + 1, 0) Then
' << Today is the last day of the month >>
Else
' << Today is not the last day of the month>>
End If

Notice I use the VBA Date function and not the VBA Now function (Now
contains time of day which is immaterial).

Rick
 
D

Dave Peterson

Another one...

if month(date) = month(date+1) then
'not the last day of the month
else
'is the last day of the month
end if
 
P

pswanie

jip great stuff!!!!

worked.

(i should have said if yesterday were the last day. in other words check if
today is the first day of the month)

But ill play around with your answer

thanx

Phillip
 
R

Ron Coderre

Nice and concise, Dave....I like that approach.

Best Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)
 
D

Dave Peterson

Maybe even
if day(date+1) = 1 then



Ron said:
Nice and concise, Dave....I like that approach.

Best Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)
 
R

Ron Coderre

Awww....Now you're just showing off! <g>

Best Regards,

Ron
Microsoft MVP (Excel)
(XL2003, Win XP)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top