Returning a complicated date formula

Rivermark

New Member
Joined
Jan 27, 2011
Messages
16
Here is my dilemma,

I need a date returned for a set of certain criteria:

In a cell in worksheet "invoice" I need this date based off of data in worksheet "roster".
A row in worksheet "roster" contains a single text character in 31 consecutive columns with headers labled 1-31
If a cell contains an "o" I need the header number it falls under to correspond with the month and year this billing cycle falls under, which is listed in cells above the headers. (ex. January is entered in A1 and 2011 is entered in A2)
I also need the month that is entered in A1 to return its number instead of it's name (ex. January=1, February=2, March=3,...)

I need the cell in worksheet "invoice" to read in the format of 1/1/2011 based on the above criteria.

Any help or direction would be appreciated.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
I need the cell in worksheet "invoice" to read in the format of 1/1/2011 based on the above criteria.

Assuming that by format of 1/1/2011, you mean M/D/YYYY format and not D/M/YYYY, this formula should work in your sheet Invoice:

=TEXT(DATEVALUE(Roster!$A$1&" "&MATCH("o",Roster!A$4:AE$4)&", "&Roster!$A$2),"M/D/YYYY")

This is based on your description of the first few columns of sheet Roster looking like this:

<b>Roster</b><br /><br /><table border="1" cellspacing="0" cellpadding="0" style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; padding-left:2pt; padding-right:2pt; "> <colgroup><col style="font-weight:bold; width:30px; " /><col style="width:57px;" /><col style="width:26px;" /><col style="width:26px;" /><col style="width:26px;" /><col style="width:26px;" /><col style="width:26px;" /><col style="width:26px;" /></colgroup><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td > </td><td >A</td><td >B</td><td >C</td><td >D</td><td >E</td><td >F</td><td >G</td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >1</td><td style="text-align:left; ">January</td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >2</td><td style="text-align:left; ">2011</td><td > </td><td > </td><td > </td><td > </td><td > </td><td > </td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >3</td><td style="text-align:right; ">1</td><td style="text-align:center; ">2</td><td style="text-align:center; ">3</td><td style="text-align:center; ">4</td><td style="text-align:center; ">5</td><td style="text-align:center; ">6</td><td style="text-align:center; ">7</td></tr><tr style="height:18px ;" ><td style="font-size:8pt; background-color:#cacaca; text-align:center; " >4</td><td > </td><td > </td><td > </td><td style="text-align:center; ">o</td><td > </td><td > </td><td > </td></tr></table> <br />Excel tables to the web - Excel Jeanie Html 4


As an alternative to using the TEXT function you could format the cell format to M/D/YYYY.
 
Last edited:
Upvote 0
The formula assumes the value of Cell A1 = January and
Cell A2=2011 (without quotes).

It would have an error if for example the value in A1 = 1/1/11 and you are using formatting to display January.

Also, what version of Excel are you using?

Please check to see if that is the difference.
 
Upvote 0
Jerry,

It looks as if the "MATCH("o",Roster!A$4:AE$4)" part is giving me the problem. It is not returning the desired number of day of month. The "January" and the "2011" is working in the evaluation.

Thanks for your patience here.
 
Upvote 0
Jerry,

It looks as if the "MATCH("o",Roster!A$4:AE$4)" part is giving me the problem. It is not returning the desired number of day of month. The "January" and the "2011" is working in the evaluation.

Thanks for your patience here.

Ah! I missed a piece of info for you, in row 4 in each column there is another letter in the cell or a blank. But, I am still looking for the one that has the "o" under it.
 
Upvote 0
Ah! I missed a piece of info for you, in row 4 in each column there is another letter in the cell or a blank. But, I am still looking for the one that has the "o" under it.

If you enter just: =MATCH("o",Roster!A$4:AE$4)
do you get #N/A?

maybe your "o" isnt really an "o" but a symbol or something.

Try changing your symbol temporarily to "X"
and test for =MATCH("X",Roster!A$4:AE$4)
 
Upvote 0
If you enter just: =MATCH("o",Roster!A$4:AE$4)
do you get #N/A?

maybe your "o" isnt really an "o" but a symbol or something.

Try changing your symbol temporarily to "X"
and test for =MATCH("X",Roster!A$4:AE$4)

You should add the match type parameter too....a 0 for exact match.
=MATCH("X",Roster!A$4:AE$4,0) <!-- / message --><!-- sig -->
 
Upvote 0
You should add the match type parameter too....a 0 for exact match.
=MATCH("X",Roster!A$4:AE$4,0) <!-- / message --><!-- sig -->


Jerry,

That work's perfectly! You're awesome.

The last thing that I would like this formula to do is, if there is not a "o" in the row that it will return just a blank cell
 
Upvote 0
The last thing that I would like this formula to do is, if there is not a "o" in the row that it will return just a blank cell

If you have xl2007, you can use the IFERROR function...
=IFERROR(TEXT(DATEVALUE(Roster!$A$1&" "&MATCH("o",Roster!A$4:AE$4,0)&", "&Roster!$A$2),"M/D/YYYY"),"")

For xl2003, I think this will work...
=IF(ISNA(TEXT(DATEVALUE(Roster!$A$1&" "&MATCH("o",Roster!A$4:AE$4,0)&", "&Roster!$A$2),"M/D/YYYY")),"",TEXT(DATEVALUE(Roster!$A$1&" "&MATCH("o",Roster!A$4:AE$4,0)&", "&Roster!$A$2),"M/D/YYYY"))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,514
Messages
6,179,225
Members
452,896
Latest member
IGT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top