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



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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 247
Default 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


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



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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


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



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
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
excel to make the days cary over month to month automaticly GARY New Users to Excel 1 April 19th 08 06:05 PM
Check Input for Valid Month SLW612 Excel Programming 4 October 21st 07 08:27 PM
check for last day of month pswanie Excel Programming 11 September 26th 07 08:20 PM
Last Saturday of each month(check on Monday) jimmy[_5_] Excel Programming 16 May 13th 07 12:45 AM
Check month jimmy[_5_] Excel Programming 10 March 4th 07 08:48 PM


All times are GMT +1. The time now is 09:54 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"