ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   check if is last day of month then, else (https://www.excelbanter.com/excel-programming/407782-check-if-last-day-month-then-else.html)

pswanie

check if is last day of month then, else
 
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

Ron Coderre

check if is last day of month then, else
 
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)

"pswanie" wrote in message
...
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




Rick Rothstein \(MVP - VB\)[_1496_]

check if is last day of month then, else
 
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


"pswanie" wrote in message
...
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



Dave Peterson

check if is last day of month then, else
 
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



pswanie wrote:

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


--

Dave Peterson

pswanie

check if is last day of month then, else
 
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

Ron Coderre

check if is last day of month then, else
 
Nice and concise, Dave....I like that approach.

Best Regards,

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

"Dave Peterson" wrote in message
...
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



pswanie wrote:

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


--

Dave Peterson




Dave Peterson

check if is last day of month then, else
 
Maybe even
if day(date+1) = 1 then



Ron Coderre wrote:

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

Best Regards,

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

"Dave Peterson" wrote in message
...
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



pswanie wrote:

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


--

Dave Peterson


--

Dave Peterson

Rick Rothstein \(MVP - VB\)[_1499_]

check if is last day of month then, else
 
Maybe even
if day(date+1) = 1 then


I really like that one!

Rick


Ron Coderre wrote:

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

Best Regards,

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

"Dave Peterson" wrote in message
...
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



pswanie wrote:

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

--

Dave Peterson


--

Dave Peterson



Ron Coderre

check if is last day of month then, else
 
Awww....Now you're just showing off! <g

Best Regards,

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


"Dave Peterson" wrote in message
...
Maybe even
if day(date+1) = 1 then



Ron Coderre wrote:

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

Best Regards,

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

"Dave Peterson" wrote in message
...
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



pswanie wrote:

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

--

Dave Peterson


--

Dave Peterson




Dave Peterson

check if is last day of month then, else
 
Nope. Just fixing the last one <vbg.

Ron Coderre wrote:

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

Best Regards,

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

"Dave Peterson" wrote in message
...
Maybe even
if day(date+1) = 1 then



Ron Coderre wrote:

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

Best Regards,

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

"Dave Peterson" wrote in message
...
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



pswanie wrote:

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

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 03:23 AM.

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