PC Review


Reply
Thread Tools Rate Thread

Inserting dates

 
 
murfitUK
Guest
Posts: n/a
 
      15th Mar 2006
Is this possible?

I have two cells which are filled in by choosing from drop-down lists. A1
is January, February etc and B1 is 2006, 2007 etc.

Once the user chooses the month & year I would like Excel to automatically
fill in some fields further down the sheet - showing the Friday dates in the
month/year chosen.

EG

Choosing March 2007 would give:
Friday 2
Friday 9
Friday 16
Friday 23
Friday 30

or August 2006 would give:
Friday 4
Friday 11
Friday 18
Friday 25
(and then a blank cell as only 4 Fridays in this month)

I can type "Friday" in as text in eg A15-A19 and then use conditional
formatting to hide the A19 Friday if there are only 4 Fridays in the month -
I will do this by turning the font colour to white if B19 is empty. That's
the easy part!

But... Is there any formula to calculate the day numbers to go into B15-B19?

All help/suggestion gratefully received.

Thanks.


 
Reply With Quote
 
 
 
 
Biff
Guest
Posts: n/a
 
      15th Mar 2006
Hi!

Since you're not using a full date format from either drop down you'll have
to create a little table so that you can generate a date. You'll see in the
final formula why this is necessary.

Create a list of the month names:

G1 = January
G2 = February
...
G12 = December

You may already have a list like this that you use as the source for month
drop down.

Select cells A15:A19 and give them a custom format of: dddd d.

Enter this formula in A15 and copy down to A19:

=IF(TEXT(DATE(B$1,MATCH(A$1,G$1:G$12,0),1+1*ROWS($1:1)*7)-WEEKDAY(DATE(B$1,MATCH(A$1,G$1:G$12,0),8-6)),"mmmm")=A$1,DATE(B$1,MATCH(A$1,G$1:G$12,0),1+1*ROWS($1:1)*7)-WEEKDAY(DATE(B$1,MATCH(A$1,G$1:G$12,0),8-6)),"")

Kinda ugly, ain't it?

We can shorten it a little by replacing the references to MATCH with a cell
reference. That's what you needed the table for. For example, use a cell to
hold the month number, say, cell C1:

=MATCH(A1,G1:G12,0)

Then you can refer to that cell instead of using the MATCH inside the DATE
function:

=IF(TEXT(DATE(B$1,C$1,1+1*ROWS($1:1)*7)-WEEKDAY(DATE(B$1,C$1,8-6)),"mmmm")=A$1,DATE(B$1,C$1,1+1*ROWS($1:1)*7)-WEEKDAY(DATE(B$1,C$1,8-6)),"")

Another way to do this would be to use 2 different formulas, one formula to
find the first Friday of the selected month/year in cell A15 and then in the
subsequent cells, A16:A19, have a differnt formula that adds 7, 14, 21 or 28
days (if needed).

I like the "one formula fits all" method, myself.

Biff

"murfitUK" <(E-Mail Removed)> wrote in message
news:8rNRf.1450$(E-Mail Removed)...
> Is this possible?
>
> I have two cells which are filled in by choosing from drop-down lists. A1
> is January, February etc and B1 is 2006, 2007 etc.
>
> Once the user chooses the month & year I would like Excel to automatically
> fill in some fields further down the sheet - showing the Friday dates in
> the month/year chosen.
>
> EG
>
> Choosing March 2007 would give:
> Friday 2
> Friday 9
> Friday 16
> Friday 23
> Friday 30
>
> or August 2006 would give:
> Friday 4
> Friday 11
> Friday 18
> Friday 25
> (and then a blank cell as only 4 Fridays in this month)
>
> I can type "Friday" in as text in eg A15-A19 and then use conditional
> formatting to hide the A19 Friday if there are only 4 Fridays in the
> month - I will do this by turning the font colour to white if B19 is
> empty. That's the easy part!
>
> But... Is there any formula to calculate the day numbers to go into
> B15-B19?
>
> All help/suggestion gratefully received.
>
> Thanks.
>



 
Reply With Quote
 
Ron Rosenfeld
Guest
Posts: n/a
 
      15th Mar 2006
On Wed, 15 Mar 2006 05:16:52 GMT, "murfitUK"
<(E-Mail Removed)> wrote:

>Is this possible?
>
>I have two cells which are filled in by choosing from drop-down lists. A1
>is January, February etc and B1 is 2006, 2007 etc.
>
>Once the user chooses the month & year I would like Excel to automatically
>fill in some fields further down the sheet - showing the Friday dates in the
>month/year chosen.
>
>EG
>
>Choosing March 2007 would give:
>Friday 2
>Friday 9
>Friday 16
>Friday 23
>Friday 30
>
>or August 2006 would give:
>Friday 4
>Friday 11
>Friday 18
>Friday 25
>(and then a blank cell as only 4 Fridays in this month)
>
>I can type "Friday" in as text in eg A15-A19 and then use conditional
>formatting to hide the A19 Friday if there are only 4 Fridays in the month -
>I will do this by turning the font colour to white if B19 is empty. That's
>the easy part!
>
>But... Is there any formula to calculate the day numbers to go into B15-B19?
>
>All help/suggestion gratefully received.
>
>Thanks.
>


Use these formulas:

A15:
=IF(ISERR(DATEVALUE(A1 & " " & B1)),"",DATEVALUE(
A1 & " " & B1)+7-WEEKDAY(DATEVALUE(A1 & " " & B1)+1))

A16: =IF(ISERR(A15+7),"",A15+7)
copy/drag down to A18

A19: =IF(ISERR(A18+7),"",IF(MONTH(A18+7)=MONTH(A18),A18+7,""))

Select the range and custom format as "dddd d"

Format/Cells/Number Custom Type: "dddd d"

This will give you the result in a single cell.

If you want it in two cells, you could, for example, change the format to
"dddd".

Then,

B15: =A15

Copy/drag down to B19

Custom format as "d"




--ron
 
Reply With Quote
 
Biff
Guest
Posts: n/a
 
      15th Mar 2006
>DATEVALUE(A1 & " " & B1)

Never saw that one before!

That can be very useful, as you've demonstrated.

Biff

"Ron Rosenfeld" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> On Wed, 15 Mar 2006 05:16:52 GMT, "murfitUK"
> <(E-Mail Removed)> wrote:
>
>>Is this possible?
>>
>>I have two cells which are filled in by choosing from drop-down lists. A1
>>is January, February etc and B1 is 2006, 2007 etc.
>>
>>Once the user chooses the month & year I would like Excel to automatically
>>fill in some fields further down the sheet - showing the Friday dates in
>>the
>>month/year chosen.
>>
>>EG
>>
>>Choosing March 2007 would give:
>>Friday 2
>>Friday 9
>>Friday 16
>>Friday 23
>>Friday 30
>>
>>or August 2006 would give:
>>Friday 4
>>Friday 11
>>Friday 18
>>Friday 25
>>(and then a blank cell as only 4 Fridays in this month)
>>
>>I can type "Friday" in as text in eg A15-A19 and then use conditional
>>formatting to hide the A19 Friday if there are only 4 Fridays in the
>>month -
>>I will do this by turning the font colour to white if B19 is empty.
>>That's
>>the easy part!
>>
>>But... Is there any formula to calculate the day numbers to go into
>>B15-B19?
>>
>>All help/suggestion gratefully received.
>>
>>Thanks.
>>

>
> Use these formulas:
>
> A15:
> =IF(ISERR(DATEVALUE(A1 & " " & B1)),"",DATEVALUE(
> A1 & " " & B1)+7-WEEKDAY(DATEVALUE(A1 & " " & B1)+1))
>
> A16: =IF(ISERR(A15+7),"",A15+7)
> copy/drag down to A18
>
> A19: =IF(ISERR(A18+7),"",IF(MONTH(A18+7)=MONTH(A18),A18+7,""))
>
> Select the range and custom format as "dddd d"
>
> Format/Cells/Number Custom Type: "dddd d"
>
> This will give you the result in a single cell.
>
> If you want it in two cells, you could, for example, change the format to
> "dddd".
>
> Then,
>
> B15: =A15
>
> Copy/drag down to B19
>
> Custom format as "d"
>
>
>
>
> --ron



 
Reply With Quote
 
hansyt@gmx.de
Guest
Posts: n/a
 
      15th Mar 2006
You could try this:

november 2007

Friday 2
Friday 9
Friday 16
Friday 23
Friday 30

Formula in B3:

=1+(5-WEEKDAY("1."& $A$1&" "&$B$1;2))+7*(WEEKDAY("1."& $A$1&"
"&$B$1;2)>5)

Formula in B4 and copied down to B7:

=(B3+7)*(DAY(EOMONTH("1."&$A$1&" "&$B$1;0))>=B3+7)

Hans

 
Reply With Quote
 
Ron Rosenfeld
Guest
Posts: n/a
 
      15th Mar 2006
On Wed, 15 Mar 2006 02:12:15 -0500, "Biff" <(E-Mail Removed)> wrote:

>>DATEVALUE(A1 & " " & B1)

>
>Never saw that one before!
>
>That can be very useful, as you've demonstrated.
>
>Biff
>


It's especially useful when, as in this instance, the dates are presented in an
unambiguous fashion. The function will (again in this instance), as written,
return the first of the month.
--ron
 
Reply With Quote
 
murfitUK
Guest
Posts: n/a
 
      15th Mar 2006
To Ron and Biff...

I tried both your methods, and copied & pasted the formulas (formulae?) just
as you said. And they both worked first time!

I have absolutely no idea what your formulas mean or how you managed to
worked them out so I am in awe of your skills.

Thank you both very much.

To Hans. I got an error with your formula - something to do with $B$1.
Sorry. But thanks for trying to help.



 
Reply With Quote
 
hansyt@gmx.de
Guest
Posts: n/a
 
      17th Mar 2006
Right,

it's to do with the German settings. You probably need to replace the
semicolons with commas. And maybe it doesn't like the German date "1.
February 2006".

Sorry for that.

Hans

 
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
Inserting Dates Shannan Microsoft Word Document Management 2 4th Jun 2010 06:48 AM
RE: Inserting Dates shhhhh Microsoft Excel Programming 2 6th Jan 2007 08:52 PM
Re: Inserting dates Corey Microsoft Excel Misc 0 1st Jun 2006 02:40 PM
Inserting dates =?Utf-8?B?SkRheQ==?= Microsoft Excel Misc 0 1st Jun 2006 02:26 PM
Inserting Dates =?Utf-8?B?SkRheQ==?= Microsoft Excel Misc 2 31st May 2006 01:58 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:33 AM.