PC Review


Reply
Thread Tools Rate Thread

check if is last day of month then, else

 
 
pswanie
Guest
Posts: n/a
 
      16th Mar 2008
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
 
Reply With Quote
 
 
 
 
Ron Coderre
Guest
Posts: n/a
 
      16th Mar 2008
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" <(E-Mail Removed)> wrote in message
news:8C0AB96C-5821-4E81-8D49-(E-Mail Removed)...
>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



 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      16th Mar 2008
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" <(E-Mail Removed)> wrote in message
news:8C0AB96C-5821-4E81-8D49-(E-Mail Removed)...
>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


 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      16th Mar 2008
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
 
Reply With Quote
 
pswanie
Guest
Posts: n/a
 
      16th Mar 2008
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
 
Reply With Quote
 
Ron Coderre
Guest
Posts: n/a
 
      16th Mar 2008
Nice and concise, Dave....I like that approach.

Best Regards,

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

"Dave Peterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      17th Mar 2008
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
 
Reply With Quote
 
Rick Rothstein \(MVP - VB\)
Guest
Posts: n/a
 
      17th Mar 2008
> 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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > 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


 
Reply With Quote
 
Ron Coderre
Guest
Posts: n/a
 
      17th Mar 2008
Awww....Now you're just showing off! <g>

Best Regards,

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


"Dave Peterson" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > 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



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      17th Mar 2008
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> > 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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check Date, Include dates from rest of month and all of next month MSchmidty2 Microsoft Excel Programming 4 28th Jul 2009 05:08 PM
check for last day of month =?Utf-8?B?cHN3YW5pZQ==?= Microsoft Excel Programming 11 26th Sep 2007 08:20 PM
Check month jimmy Microsoft Excel Programming 10 4th Mar 2007 08:48 PM
printing Little Current month and Little Next month on Banner when it should little PRIOR month and little Next month. jake_allen10@hotmail.com Microsoft Outlook 0 3rd Nov 2006 07:30 PM
check day as well as month kaplonk Microsoft Excel Misc 3 11th Aug 2004 01:53 PM


Features
 

Advertising
 

Newsgroups
 


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