PC Review


Reply
Thread Tools Rate Thread

Assigning a date that is before expiration date

 
 
Visakha
Guest
Posts: n/a
 
      30th Sep 2009
I have a spreadsheet that list when authorizations expire. Before the
expiration date, the authorization must be renewed in a meeting that occurs
every Wednesday. Thus far, the assigning of the renewal meetings has been
done manually. Is the a macro or lookup function that does this
automatically?

Example: if expiration is on 10/19/09, then assign to Wednesday date before
or on 10/19/09. Cell to show 10/21/09.

Thanks in advance!


 
Reply With Quote
 
 
 
 
Member
Join Date: Sep 2009
Posts: 45
 
      1st Oct 2009
suppose date is in A1

try this in B1

=IF(WEEKDAY(A1)<=4,A1+4-WEEKDAY(A1),A1+4-WEEKDAY(A1)+7)

you can copy B1 down
 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      1st Oct 2009
Hi Visakha

You example and description contradicts.. However both options are given
below. Test and feedback

> Example: if expiration is on 10/19/09, then assign to Wednesday date before
> or on 10/19/09. Cell to show 10/21/09.



Sub Macro2()
Dim myDate As Date
myDate = DateValue("10/14/2009")

MsgBox "Wednesday before or current: " & DateAdd("d", _
IIf(Weekday(myDate) < 4, -3, 4) - Weekday(myDate), myDate)

MsgBox "Wednesday after or current: " & DateAdd("d", _
IIf(Weekday(myDate) <= 4, 4, 11) - Weekday(myDate), myDate)

End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Visakha" wrote:

> I have a spreadsheet that list when authorizations expire. Before the
> expiration date, the authorization must be renewed in a meeting that occurs
> every Wednesday. Thus far, the assigning of the renewal meetings has been
> done manually. Is the a macro or lookup function that does this
> automatically?
>
> Example: if expiration is on 10/19/09, then assign to Wednesday date before
> or on 10/19/09. Cell to show 10/21/09.
>
> Thanks in advance!
>
>

 
Reply With Quote
 
Visakha
Guest
Posts: n/a
 
      2nd Oct 2009
Hi Jacob,

Thanks for catching that--I meant before or on. And yes, this macro works
but I am wondering how to apply it a column of cells. Say the expiration
dates are listed in column b (reiterating to up to 1000). Is there a way to
show the assigned date in column C instead of a dialog box? I am fairly new
to macros but am enjoying them! Thanks so much!

"Jacob Skaria" wrote:

> Hi Visakha
>
> You example and description contradicts.. However both options are given
> below. Test and feedback
>
> > Example: if expiration is on 10/19/09, then assign to Wednesday date before
> > or on 10/19/09. Cell to show 10/21/09.

>
>
> Sub Macro2()
> Dim myDate As Date
> myDate = DateValue("10/14/2009")
>
> MsgBox "Wednesday before or current: " & DateAdd("d", _
> IIf(Weekday(myDate) < 4, -3, 4) - Weekday(myDate), myDate)
>
> MsgBox "Wednesday after or current: " & DateAdd("d", _
> IIf(Weekday(myDate) <= 4, 4, 11) - Weekday(myDate), myDate)
>
> End Sub
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Visakha" wrote:
>
> > I have a spreadsheet that list when authorizations expire. Before the
> > expiration date, the authorization must be renewed in a meeting that occurs
> > every Wednesday. Thus far, the assigning of the renewal meetings has been
> > done manually. Is the a macro or lookup function that does this
> > automatically?
> >
> > Example: if expiration is on 10/19/09, then assign to Wednesday date before
> > or on 10/19/09. Cell to show 10/21/09.
> >
> > Thanks in advance!
> >
> >

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      3rd Oct 2009
You dont need a VBA solution to do this. With dates in Column B starting from
cell B1; in C1 enter formula

=B1+IF(WEEKDAY(B1)<4,-3,4)-WEEKDAY(B1)
and copy down as required

If this post helps click Yes
---------------
Jacob Skaria


"Visakha" wrote:

> Hi Jacob,
>
> Thanks for catching that--I meant before or on. And yes, this macro works
> but I am wondering how to apply it a column of cells. Say the expiration
> dates are listed in column b (reiterating to up to 1000). Is there a way to
> show the assigned date in column C instead of a dialog box? I am fairly new
> to macros but am enjoying them! Thanks so much!
>
> "Jacob Skaria" wrote:
>
> > Hi Visakha
> >
> > You example and description contradicts.. However both options are given
> > below. Test and feedback
> >
> > > Example: if expiration is on 10/19/09, then assign to Wednesday date before
> > > or on 10/19/09. Cell to show 10/21/09.

> >
> >
> > Sub Macro2()
> > Dim myDate As Date
> > myDate = DateValue("10/14/2009")
> >
> > MsgBox "Wednesday before or current: " & DateAdd("d", _
> > IIf(Weekday(myDate) < 4, -3, 4) - Weekday(myDate), myDate)
> >
> > MsgBox "Wednesday after or current: " & DateAdd("d", _
> > IIf(Weekday(myDate) <= 4, 4, 11) - Weekday(myDate), myDate)
> >
> > End Sub
> >
> > If this post helps click Yes
> > ---------------
> > Jacob Skaria
> >
> >
> > "Visakha" wrote:
> >
> > > I have a spreadsheet that list when authorizations expire. Before the
> > > expiration date, the authorization must be renewed in a meeting that occurs
> > > every Wednesday. Thus far, the assigning of the renewal meetings has been
> > > done manually. Is the a macro or lookup function that does this
> > > automatically?
> > >
> > > Example: if expiration is on 10/19/09, then assign to Wednesday date before
> > > or on 10/19/09. Cell to show 10/21/09.
> > >
> > > Thanks in advance!
> > >
> > >

 
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
assigning a null value of a date field to a date variable George Microsoft Access Form Coding 4 3rd May 2008 11:50 AM
Dealing with date formats on expiration date bliten_bsas Microsoft Excel Programming 1 4th Oct 2007 08:47 PM
i have two date fileds Opend date Due date, can i set default on due date so, its always = to open date on my data entry form1 Urgent Mike Saifie Microsoft Access Form Coding 1 9th Mar 2006 01:08 AM
Expiration Date Muhammad-Ali Younes Spyware Discussion 10 26th Jun 2005 03:25 AM
Re: Assigning Date value to Date/Time field (=midnight?) John Spencer (MVP) Microsoft Access VBA Modules 1 8th Aug 2003 08:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:59 PM.