Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 256
Default separate cell values with formulas - can this be improved?

OK, bear with me because this is kind of obfuscated.

I am working with a monthly invoice. On the invoice, we have Period
Start and Period End date. These will usually be first and last of
the month. We are billing for a service whose rate varies based on
whether it is a weekend or a weekday. We receive information from
service department regarding which days services were not performed,
and list them on the invoice.

Here's an example (without the " "s):

(stored as dates)
B22 = July 1, 2007
D22 = July 31, 2007
(text entries)
E22 = "(Off on July "
F22 = "1,2,3,6,9,10,12,15 = 8 days)"

Now, we need to adjust number of billable days based on whether each
day is a weekday or a weekend.

In cells J1:J31, i have this formula: =MID($F
$22,IFERROR(FIND(CHAR(150),SUBSTITUTE($F$22,",",CH AR(150),ROW()-1))
+1,1),FIND(CHAR(150),SUBSTITUTE($F$22,",",CHAR(150 ),ROW()))-
IFERROR(FIND(CHAR(150),SUBSTITUTE($F$22,",",CHAR(1 50),ROW()-1))+1,1))

This extracts each number (1,2,3,6,9,10,12,15). Now, in the main
portion of the invoice I have these two array formulas:

=NETWORKDAYS(B22,D22)-SUM(IFERROR(--
(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J31),2)<6)," "))&" Weekdays
(10hrs per day)"

and

=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IFERROR(--
(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J31),2)5)," "))&" Weekends
(16hrs per day)"

My question is: can I do this somehow without using the helper column
(J)? I couldn't think of another way to find each subsequent comma,
perhaps there is a more clever way of using the SUBSTITUTE function?

I would like this to be a template that anyone can use, and have to do
nothing besides fill in the two dates and the non-service days. While
it's not a problem hiding the J column, there's still a chance it
might get deleted or rows inserted to screw up the calculation.

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 434
Default separate cell values with formulas - can this be improved?

hi, ilia !

[I guess] you could by-pass the helper column (J) and *construct* an array constant by...
using named-formulae [insert name define...] and the ancient 'evaluate' xl4-macro function [i.e.]
[assuming you need ONLY the *days* portion of a single-cell $F$22]

name: nDays
formula: =evaluate("{"&left(!$f$22,search(" ",!$f$22)-1)&"}")

note the signs '!', it is important !!!

now, you can substitute in your array-formulae any reference to range J1:J31 with *the name* [nDays]

NOTES:

a) there is a possibe 'risk' of an xl-crash... while defining names as suggested...
if you copy the worksheets that uses them [at least, in xl-97 & 2000] so...
use this proposal on your own... risk, criteria, modifications, etc.

b) also, if you need this procedure to be used in NON-english xl versions -?-
you will need to find out the character for rows separator in constant arrays by...
defining another named formula [i.e.]

name: rS
formula: =index(get.workspace(37),15)

and change the formula for nDays name to:
=evaluate("{"&substitute(left(!$f$22,search(" ",!$f$22)-1),",",rs)&"}")

[just wild ideas]
hth,
hector.

__ original post __
I am working with a monthly invoice. On the invoice, we have Period Start and Period End date.
These will usually be first and last of the month.
We are billing for a service whose rate varies based on whether it is a weekend or a weekday.
We receive information from service department regarding which days services were not performed, and list them on the invoice.

Here's an example (without the " "s):

(stored as dates)
B22 = July 1, 2007
D22 = July 31, 2007
(text entries)
E22 = "(Off on July "
F22 = "1,2,3,6,9,10,12,15 = 8 days)"

Now, we need to adjust number of billable days based on whether each day is a weekday or a weekend.

In cells J1:J31, i have this formula: =MID($F$22,IFERROR(FIND(CHAR(150),SUBSTITUTE($F$22 ,",",CHAR(150),ROW()-1))
+1,1),FIND(CHAR(150),SUBSTITUTE($F$22,",",CHAR(150 ),ROW()))-IFERROR(FIND(CHAR(150),
SUBSTITUTE($F$22,",",CHAR(150),ROW()-1))+1,1))

This extracts each number (1,2,3,6,9,10,12,15).
Now, in the main portion of the invoice I have these two array formulas:
=NETWORKDAYS(B22,D22)-SUM(IFERROR(--(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J31),2)<6)," "))&" Weekdays (10hrs per day)"
and
=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IFERROR(--(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J31),2)5)," "))&" Weekends (16hrs per day)"

My question is: can I do this somehow without using the helper column (J)?
I couldn't think of another way to find each subsequent comma, perhaps there is a more clever way of using the SUBSTITUTE function?

I would like this to be a template that anyone can use, and have to do nothing besides fill in the two dates and the non-service days.
While it's not a problem hiding the J column, there's still a chance it might get deleted or rows inserted to screw up the calculation.



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 434
Default separate cell values with formulas - can this be improved?

hi [again], guys !

using the *tricky* named formula for nDays...

=sumproduct(--(weekday(date(year(b22),month(b22),ndays),2)<6))&" weekdays (10 hrs per day)"
=sumproduct(--(weekday(date(year(b22),month(b22),ndays),2)5))&" weekends (16 hrs per day)"

hth,
hector.

__ previous posts __
[I guess] you could by-pass the helper column (J) and *construct* an array constant by...
using named-formulae [insert name define...] and the ancient 'evaluate' xl4-macro function [i.e.]
[assuming you need ONLY the *days* portion of a single-cell $F$22]

name: nDays
formula: =evaluate("{"&left(!$f$22,search(" ",!$f$22)-1)&"}")

note the signs '!', it is important !!!

now, you can substitute in your array-formulae any reference to range J1:J31 with *the name* [nDays]

NOTES:

a) there is a possibe 'risk' of an xl-crash... while defining names as suggested...
if you copy the worksheets that uses them [at least, in xl-97 & 2000] so...
use this proposal on your own... risk, criteria, modifications, etc.

b) also, if you need this procedure to be used in NON-english xl versions -?-
you will need to find out the character for rows separator in constant arrays by...
defining another named formula [i.e.]

name: rS
formula: =index(get.workspace(37),15)

and change the formula for nDays name to:
=evaluate("{"&substitute(left(!$f$22,search(" ",!$f$22)-1),",",rs)&"}")

[just wild ideas]
hth,
hector.

__ original post __
I am working with a monthly invoice. On the invoice, we have Period Start and Period End date.
These will usually be first and last of the month.
We are billing for a service whose rate varies based on whether it is a weekend or a weekday.
We receive information from service department regarding which days services were not performed, and list them on the invoice.

Here's an example (without the " "s):

(stored as dates)
B22 = July 1, 2007
D22 = July 31, 2007
(text entries)
E22 = "(Off on July "
F22 = "1,2,3,6,9,10,12,15 = 8 days)"

Now, we need to adjust number of billable days based on whether each day is a weekday or a weekend.

In cells J1:J31, i have this formula: =MID($F$22,IFERROR(FIND(CHAR(150),SUBSTITUTE($F$22 ,",",CHAR(150),ROW()-1))
+1,1),FIND(CHAR(150),SUBSTITUTE($F$22,",",CHAR(150 ),ROW()))-IFERROR(FIND(CHAR(150),
SUBSTITUTE($F$22,",",CHAR(150),ROW()-1))+1,1))

This extracts each number (1,2,3,6,9,10,12,15).
Now, in the main portion of the invoice I have these two array formulas:
=NETWORKDAYS(B22,D22)-SUM(IFERROR(--(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J31),2)<6)," "))&" Weekdays (10hrs per day)"
and
=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IFERROR(--(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J31),2)5)," "))&" Weekends (16hrs per day)"

My question is: can I do this somehow without using the helper column (J)?
I couldn't think of another way to find each subsequent comma, perhaps there is a more clever way of using the SUBSTITUTE function?

I would like this to be a template that anyone can use, and have to do nothing besides fill in the two dates and the non-service days.
While it's not a problem hiding the J column, there's still a chance it might get deleted or rows inserted to screw up the calculation.





  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 256
Default separate cell values with formulas - can this be improved?

OK, first a correction to my original helper column. I'm making heavy
use of the new IFERROR function, so bear with me if you're using an
earlier version.

=MID($F$22,IFERROR(FIND(CHAR(150),SUBSTITUTE($F
$22,",",CHAR(150),ROW()-1))+1,1),IFERROR(FIND(CHAR(150),SUBSTITUTE($F
$22,",",CHAR(150),ROW())),FIND(CHAR(150),SUBSTITUT E($F$22," =
",CHAR(150),1)))-IFERROR(FIND(CHAR(150),SUBSTITUTE($F
$22,",",CHAR(150),ROW()-1))+1,1))

This assumes that if a comma is not found, the next separator will be
" = ". There are two problems with this: (1) it relies on this list
always starting in the first row, and (2) it is unable to omit any
text prior to the first day number (in case I want to combine E22 and
F22, for example).

The two array formulas proposed instead work (thanks Biff). I think
I'm going to end up doing that. I couldn't get the non-array versions
to work.

By the way, I'm not accounting for holidays because this is a 24/7/365
service (366 this fiscal year). I do use the holidays argument for
NETWORKDAYS on other types of invoices.

-Ilia


On Aug 8, 4:23 am, "Héctor Miguel"
wrote:
hi [again], guys !

using the *tricky* named formula for nDays...

=sumproduct(--(weekday(date(year(b22),month(b22),ndays),2)<6))&" weekdays (10 hrs per day)"
=sumproduct(--(weekday(date(year(b22),month(b22),ndays),2)5))&" weekends (16 hrs per day)"

hth,
hector.

__ previous posts __



[I guess] you could by-pass the helper column (J) and *construct* an array constant by...
using named-formulae [insert name define...] and the ancient 'evaluate' xl4-macro function [i.e.]
[assuming you need ONLY the *days* portion of a single-cell $F$22]


name: nDays
formula: =evaluate("{"&left(!$f$22,search(" ",!$f$22)-1)&"}")


note the signs '!', it is important !!!


now, you can substitute in your array-formulae any reference to range J1:J31 with *the name* [nDays]


NOTES:


a) there is a possibe 'risk' of an xl-crash... while defining names as suggested...
if you copy the worksheets that uses them [at least, in xl-97 & 2000] so...
use this proposal on your own... risk, criteria, modifications, etc.


b) also, if you need this procedure to be used in NON-english xl versions -?-
you will need to find out the character for rows separator in constant arrays by...
defining another named formula [i.e.]


name: rS
formula: =index(get.workspace(37),15)


and change the formula for nDays name to:
=evaluate("{"&substitute(left(!$f$22,search(" ",!$f$22)-1),",",rs)&"}")


[just wild ideas]
hth,
hector.


__ original post __
I am working with a monthly invoice. On the invoice, we have Period Start and Period End date.
These will usually be first and last of the month.
We are billing for a service whose rate varies based on whether it is a weekend or a weekday.
We receive information from service department regarding which days services were not performed, and list them on the invoice.


Here's an example (without the " "s):


(stored as dates)
B22 = July 1, 2007
D22 = July 31, 2007
(text entries)
E22 = "(Off on July "
F22 = "1,2,3,6,9,10,12,15 = 8 days)"


Now, we need to adjust number of billable days based on whether each day is a weekday or a weekend.


In cells J1:J31, i have this formula: =MID($F$22,IFERROR(FIND(CHAR(150),SUBSTITUTE($F$22 ,",",CHAR(150),ROW()-1))
+1,1),FIND(CHAR(150),SUBSTITUTE($F$22,",",CHAR(150 ),ROW()))-IFERROR(FIND(CH*AR(150),
SUBSTITUTE($F$22,",",CHAR(150),ROW()-1))+1,1))


This extracts each number (1,2,3,6,9,10,12,15).
Now, in the main portion of the invoice I have these two array formulas:
=NETWORKDAYS(B22,D22)-SUM(IFERROR(--(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J*31),2)<6), ""))&" Weekdays (10hrs per day)"
and
=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IFERROR(--(WEEKDAY(DATE(YEAR(B22),MON*TH(B22),J1:J31),2)5), ""))&" Weekends (16hrs per day)"


My question is: can I do this somehow without using the helper column (J)?
I couldn't think of another way to find each subsequent comma, perhaps there is a more clever way of using the SUBSTITUTE function?


I would like this to be a template that anyone can use, and have to do nothing besides fill in the two dates and the non-service days.
While it's not a problem hiding the J column, there's still a chance it might get deleted or rows inserted to screw up the calculation.- Hide quoted text -


- Show quoted text -



  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default separate cell values with formulas - can this be improved?

I found a bug in those formulas.

F22 = 1,2,3,6,9,10,12,15 = 8 days)

How is that string generated?

You would need to delimit each day with a comma from the rest of the string.
In the above there is no comma after the 15 and that is causing the bug. So,
F22 needs to look like this:

1,2,3,6,9,10,12,15, = 8 days)

Then, the slightly modified formulas:

=NETWORKDAYS(B22,D22)-SUM(IF(ISNUMBER(FIND(","&DAY(ROW(INDIRECT(B22&":"& D22)))&",",","&F22)),IF(WEEKDAY(ROW(INDIRECT(B22&" :"&D22)),2)<6,1)))&"
Weekdays(10hrs per day)"

=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IF(ISNUMBER(FIND(","&DAY(ROW(INDIRECT(B22&":"& D22)))&",",","&F22)),IF(WEEKDAY(ROW(INDIRECT(B22&" :"&D22)),2)5,1)))&"
Weekends(16hrs per day)"

--
Biff
Microsoft Excel MVP


"ilia" wrote in message
oups.com...
OK, first a correction to my original helper column. I'm making heavy
use of the new IFERROR function, so bear with me if you're using an
earlier version.

=MID($F$22,IFERROR(FIND(CHAR(150),SUBSTITUTE($F
$22,",",CHAR(150),ROW()-1))+1,1),IFERROR(FIND(CHAR(150),SUBSTITUTE($F
$22,",",CHAR(150),ROW())),FIND(CHAR(150),SUBSTITUT E($F$22," =
",CHAR(150),1)))-IFERROR(FIND(CHAR(150),SUBSTITUTE($F
$22,",",CHAR(150),ROW()-1))+1,1))

This assumes that if a comma is not found, the next separator will be
" = ". There are two problems with this: (1) it relies on this list
always starting in the first row, and (2) it is unable to omit any
text prior to the first day number (in case I want to combine E22 and
F22, for example).

The two array formulas proposed instead work (thanks Biff). I think
I'm going to end up doing that. I couldn't get the non-array versions
to work.

By the way, I'm not accounting for holidays because this is a 24/7/365
service (366 this fiscal year). I do use the holidays argument for
NETWORKDAYS on other types of invoices.

-Ilia


On Aug 8, 4:23 am, "Héctor Miguel"
wrote:
hi [again], guys !

using the *tricky* named formula for nDays...

=sumproduct(--(weekday(date(year(b22),month(b22),ndays),2)<6))&" weekdays
(10 hrs per day)"
=sumproduct(--(weekday(date(year(b22),month(b22),ndays),2)5))&" weekends
(16 hrs per day)"

hth,
hector.

__ previous posts __



[I guess] you could by-pass the helper column (J) and *construct* an
array constant by...
using named-formulae [insert name define...] and the ancient
'evaluate' xl4-macro function [i.e.]
[assuming you need ONLY the *days* portion of a single-cell $F$22]


name: nDays
formula: =evaluate("{"&left(!$f$22,search(" ",!$f$22)-1)&"}")


note the signs '!', it is important !!!


now, you can substitute in your array-formulae any reference to range
J1:J31 with *the name* [nDays]


NOTES:


a) there is a possibe 'risk' of an xl-crash... while defining names as
suggested...
if you copy the worksheets that uses them [at least, in xl-97 & 2000]
so...
use this proposal on your own... risk, criteria, modifications, etc.


b) also, if you need this procedure to be used in NON-english xl
versions -?-
you will need to find out the character for rows separator in
constant arrays by...
defining another named formula [i.e.]


name: rS
formula: =index(get.workspace(37),15)


and change the formula for nDays name to:
=evaluate("{"&substitute(left(!$f$22,search("
",!$f$22)-1),",",rs)&"}")


[just wild ideas]
hth,
hector.


__ original post __
I am working with a monthly invoice. On the invoice, we have Period
Start and Period End date.
These will usually be first and last of the month.
We are billing for a service whose rate varies based on whether it is a
weekend or a weekday.
We receive information from service department regarding which days
services were not performed, and list them on the invoice.


Here's an example (without the " "s):


(stored as dates)
B22 = July 1, 2007
D22 = July 31, 2007
(text entries)
E22 = "(Off on July "
F22 = "1,2,3,6,9,10,12,15 = 8 days)"


Now, we need to adjust number of billable days based on whether each
day is a weekday or a weekend.


In cells J1:J31, i have this formula:
=MID($F$22,IFERROR(FIND(CHAR(150),SUBSTITUTE($F$22 ,",",CHAR(150),ROW()-1))
+1,1),FIND(CHAR(150),SUBSTITUTE($F$22,",",CHAR(150 ),ROW()))-IFERROR(FIND(CH*AR(150),
SUBSTITUTE($F$22,",",CHAR(150),ROW()-1))+1,1))


This extracts each number (1,2,3,6,9,10,12,15).
Now, in the main portion of the invoice I have these two array
formulas:
=NETWORKDAYS(B22,D22)-SUM(IFERROR(--(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J*31),2)<6), ""))&"
Weekdays (10hrs per day)"
and
=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IFERROR(--(WEEKDAY(DATE(YEAR(B22),MON*TH(B22),J1:J31),2)5), ""))&"
Weekends (16hrs per day)"


My question is: can I do this somehow without using the helper column
(J)?
I couldn't think of another way to find each subsequent comma, perhaps
there is a more clever way of using the SUBSTITUTE function?


I would like this to be a template that anyone can use, and have to do
nothing besides fill in the two dates and the non-service days.
While it's not a problem hiding the J column, there's still a chance it
might get deleted or rows inserted to screw up the calculation.- Hide
quoted text -


- Show quoted text -






  #6   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 256
Default separate cell values with formulas - can this be improved?

Yes I see what you're saying. That string is typed in by hand, so a
comma can be added theoretically

Using this formula:

=NETWORKDAYS(B22,D22)-
SUM(IF(ISNUMBER(FIND(","&DAY(ROW(INDIRECT(B22&":"& D22))),","&F22)),IF(WEEKDAY(ROW(INDIRECT(B22&":"&D 22)),
2)<6,1)))

F22 = 1,2,3,6,9,10,12,15 = 8 days)

I get the correct result for weekdays, but only if F22 value begins
with the first day. 1 and 15 are weekend days; thhe rest are
weekdays. Month is July, so there is a total of 31 days. The result
I get is 16 weekdays, 7 weekends. This is correct.

If I add anything in front of the text, the first value is omitted
because of the comma added. But I don't see how adding a comma after
the last value affects this formula? The find function is looking for
anything preceded by the comma.

Another problem with it is in the case of a value being in the second
10 days. For instance, if

F2 = 12,15 = 2 days)

The formula will evaluate both ",1" and ",12" resulting on one extra
weekend (in case of July 2007, the 1st). The new formula does work at
avoiding this problem, so it looks like adding a comma at the end
might well be the solution.

Sorry, just brain dumping. This is an interesting problem and I'm
still figuring out what's the best way to set it up, so as to develop
accurate procedures for data entry.

Thanks all.

-Ilia



On Aug 8, 1:38 pm, "T. Valko" wrote:
I found a bug in those formulas.

F22 = 1,2,3,6,9,10,12,15 = 8 days)

How is that string generated?

You would need to delimit each day with a comma from the rest of the string.
In the above there is no comma after the 15 and that is causing the bug. So,
F22 needs to look like this:

1,2,3,6,9,10,12,15, = 8 days)

Then, the slightly modified formulas:

=NETWORKDAYS(B22,D22)-SUM(IF(ISNUMBER(FIND(","&DAY(ROW(INDIRECT(B22&":"& D22*)))&",",","&F22)),IF(WEEKDAY(ROW(INDIRECT(B22& ":"&D22)),2)<6,1)))&"
Weekdays(10hrs per day)"

=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IF(ISNUMBER(FIND(","&DAY(ROW(INDIRECT*(B22&":" &D22)))&",",","&F22)),IF(WEEKDAY(ROW(INDIRECT(B22& ":"&D22)),2)5,1)*))&"
Weekends(16hrs per day)"

--
Biff
Microsoft Excel MVP

"ilia" wrote in message

oups.com...
OK, first a correction to my original helper column. I'm making heavy
use of the new IFERROR function, so bear with me if you're using an
earlier version.

=MID($F$22,IFERROR(FIND(CHAR(150),SUBSTITUTE($F
$22,",",CHAR(150),ROW()-1))+1,1),IFERROR(FIND(CHAR(150),SUBSTITUTE($F
$22,",",CHAR(150),ROW())),FIND(CHAR(150),SUBSTITUT E($F$22," =
",CHAR(150),1)))-IFERROR(FIND(CHAR(150),SUBSTITUTE($F
$22,",",CHAR(150),ROW()-1))+1,1))

This assumes that if a comma is not found, the next separator will be
" = ". There are two problems with this: (1) it relies on this list
always starting in the first row, and (2) it is unable to omit any
text prior to the first day number (in case I want to combine E22 and
F22, for example).

The two array formulas proposed instead work (thanks Biff). I think
I'm going to end up doing that. I couldn't get the non-array versions
to work.

By the way, I'm not accounting for holidays because this is a 24/7/365
service (366 this fiscal year). I do use the holidays argument for
NETWORKDAYS on other types of invoices.

-Ilia

On Aug 8, 4:23 am, "Héctor Miguel"
wrote:



hi [again], guys !


using the *tricky* named formula for nDays...


=sumproduct(--(weekday(date(year(b22),month(b22),ndays),2)<6))&" weekdays
(10 hrs per day)"
=sumproduct(--(weekday(date(year(b22),month(b22),ndays),2)5))&" weekends
(16 hrs per day)"


hth,
hector.


__ previous posts __


[I guess] you could by-pass the helper column (J) and *construct* an
array constant by...
using named-formulae [insert name define...] and the ancient
'evaluate' xl4-macro function [i.e.]
[assuming you need ONLY the *days* portion of a single-cell $F$22]


name: nDays
formula: =evaluate("{"&left(!$f$22,search(" ",!$f$22)-1)&"}")


note the signs '!', it is important !!!


now, you can substitute in your array-formulae any reference to range
J1:J31 with *the name* [nDays]


NOTES:


a) there is a possibe 'risk' of an xl-crash... while defining names as
suggested...
if you copy the worksheets that uses them [at least, in xl-97 & 2000]
so...
use this proposal on your own... risk, criteria, modifications, etc.


b) also, if you need this procedure to be used in NON-english xl
versions -?-
you will need to find out the character for rows separator in
constant arrays by...
defining another named formula [i.e.]


name: rS
formula: =index(get.workspace(37),15)


and change the formula for nDays name to:
=evaluate("{"&substitute(left(!$f$22,search("
",!$f$22)-1),",",rs)&"}")


[just wild ideas]
hth,
hector.


__ original post __
I am working with a monthly invoice. On the invoice, we have Period
Start and Period End date.
These will usually be first and last of the month.
We are billing for a service whose rate varies based on whether it is a
weekend or a weekday.
We receive information from service department regarding which days
services were not performed, and list them on the invoice.


Here's an example (without the " "s):


(stored as dates)
B22 = July 1, 2007
D22 = July 31, 2007
(text entries)
E22 = "(Off on July "
F22 = "1,2,3,6,9,10,12,15 = 8 days)"


Now, we need to adjust number of billable days based on whether each
day is a weekday or a weekend.


In cells J1:J31, i have this formula:
=MID($F$22,IFERROR(FIND(CHAR(150),SUBSTITUTE($F$22 ,",",CHAR(150),ROW()-1))
+1,1),FIND(CHAR(150),SUBSTITUTE($F$22,",",CHAR(150 ),ROW()))-IFERROR(FIND(CH**AR(150),
SUBSTITUTE($F$22,",",CHAR(150),ROW()-1))+1,1))


This extracts each number (1,2,3,6,9,10,12,15).
Now, in the main portion of the invoice I have these two array
formulas:
=NETWORKDAYS(B22,D22)-SUM(IFERROR(--(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J**31),2)<6) ,""))&"
Weekdays (10hrs per day)"
and
=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IFERROR(--(WEEKDAY(DATE(YEAR(B22),MON**TH(B22),J1:J31),2)5) ,""))&"
Weekends (16hrs per day)"


My question is: can I do this somehow without using the helper column
(J)?
I couldn't think of another way to find each subsequent comma, perhaps
there is a more clever way of using the SUBSTITUTE function?


I would like this to be a template that anyone can use, and have to do
nothing besides fill in the two dates and the non-service days.
While it's not a problem hiding the J column, there's still a chance it
might get deleted or rows inserted to screw up the calculation.- Hide
quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



  #7   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 256
Default separate cell values with formulas - can this be improved?

Yes I see what you're saying. That string is typed in by hand, so a
comma can be added theoretically

Using this formula:

=NETWORKDAYS(B22,D22)-
SUM(IF(ISNUMBER(FIND(","&DAY(ROW(INDIRECT(B22&":"& D22))),","&F22)),IF(WEEKDAY(ROW(INDIRECT(B22&":"&D 22)),
2)<6,1)))

F22 = 1,2,3,6,9,10,12,15 = 8 days)

I get the correct result for weekdays, but only if F22 value begins
with the first day. 1 and 15 are weekend days; thhe rest are
weekdays. Month is July, so there is a total of 31 days. The result
I get is 16 weekdays, 7 weekends. This is correct.

If I add anything in front of the text, the first value is omitted
because of the comma added. But I don't see how adding a comma after
the last value affects this formula? The find function is looking for
anything preceded by the comma.

Another problem with it is in the case of a value being in the second
10 days. For instance, if

F2 = 12,15 = 2 days)

The formula will evaluate both ",1" and ",12" resulting on one extra
weekend (in case of July 2007, the 1st). The new formula does work at
avoiding this problem, so it looks like adding a comma at the end
might well be the solution.

Sorry, just brain dumping. This is an interesting problem and I'm
still figuring out what's the best way to set it up, so as to develop
accurate procedures for data entry.

Thanks all.

-Ilia



On Aug 8, 1:38 pm, "T. Valko" wrote:
I found a bug in those formulas.

F22 = 1,2,3,6,9,10,12,15 = 8 days)

How is that string generated?

You would need to delimit each day with a comma from the rest of the string.
In the above there is no comma after the 15 and that is causing the bug. So,
F22 needs to look like this:

1,2,3,6,9,10,12,15, = 8 days)

Then, the slightly modified formulas:

=NETWORKDAYS(B22,D22)-SUM(IF(ISNUMBER(FIND(","&DAY(ROW(INDIRECT(B22&":"& D22*)))&",",","&F22)),IF(WEEKDAY(ROW(INDIRECT(B22& ":"&D22)),2)<6,1)))&"
Weekdays(10hrs per day)"

=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IF(ISNUMBER(FIND(","&DAY(ROW(INDIRECT*(B22&":" &D22)))&",",","&F22)),IF(WEEKDAY(ROW(INDIRECT(B22& ":"&D22)),2)5,1)*))&"
Weekends(16hrs per day)"

--
Biff
Microsoft Excel MVP

"ilia" wrote in message

oups.com...
OK, first a correction to my original helper column. I'm making heavy
use of the new IFERROR function, so bear with me if you're using an
earlier version.

=MID($F$22,IFERROR(FIND(CHAR(150),SUBSTITUTE($F
$22,",",CHAR(150),ROW()-1))+1,1),IFERROR(FIND(CHAR(150),SUBSTITUTE($F
$22,",",CHAR(150),ROW())),FIND(CHAR(150),SUBSTITUT E($F$22," =
",CHAR(150),1)))-IFERROR(FIND(CHAR(150),SUBSTITUTE($F
$22,",",CHAR(150),ROW()-1))+1,1))

This assumes that if a comma is not found, the next separator will be
" = ". There are two problems with this: (1) it relies on this list
always starting in the first row, and (2) it is unable to omit any
text prior to the first day number (in case I want to combine E22 and
F22, for example).

The two array formulas proposed instead work (thanks Biff). I think
I'm going to end up doing that. I couldn't get the non-array versions
to work.

By the way, I'm not accounting for holidays because this is a 24/7/365
service (366 this fiscal year). I do use the holidays argument for
NETWORKDAYS on other types of invoices.

-Ilia

On Aug 8, 4:23 am, "Héctor Miguel"
wrote:



hi [again], guys !


using the *tricky* named formula for nDays...


=sumproduct(--(weekday(date(year(b22),month(b22),ndays),2)<6))&" weekdays
(10 hrs per day)"
=sumproduct(--(weekday(date(year(b22),month(b22),ndays),2)5))&" weekends
(16 hrs per day)"


hth,
hector.


__ previous posts __


[I guess] you could by-pass the helper column (J) and *construct* an
array constant by...
using named-formulae [insert name define...] and the ancient
'evaluate' xl4-macro function [i.e.]
[assuming you need ONLY the *days* portion of a single-cell $F$22]


name: nDays
formula: =evaluate("{"&left(!$f$22,search(" ",!$f$22)-1)&"}")


note the signs '!', it is important !!!


now, you can substitute in your array-formulae any reference to range
J1:J31 with *the name* [nDays]


NOTES:


a) there is a possibe 'risk' of an xl-crash... while defining names as
suggested...
if you copy the worksheets that uses them [at least, in xl-97 & 2000]
so...
use this proposal on your own... risk, criteria, modifications, etc.


b) also, if you need this procedure to be used in NON-english xl
versions -?-
you will need to find out the character for rows separator in
constant arrays by...
defining another named formula [i.e.]


name: rS
formula: =index(get.workspace(37),15)


and change the formula for nDays name to:
=evaluate("{"&substitute(left(!$f$22,search("
",!$f$22)-1),",",rs)&"}")


[just wild ideas]
hth,
hector.


__ original post __
I am working with a monthly invoice. On the invoice, we have Period
Start and Period End date.
These will usually be first and last of the month.
We are billing for a service whose rate varies based on whether it is a
weekend or a weekday.
We receive information from service department regarding which days
services were not performed, and list them on the invoice.


Here's an example (without the " "s):


(stored as dates)
B22 = July 1, 2007
D22 = July 31, 2007
(text entries)
E22 = "(Off on July "
F22 = "1,2,3,6,9,10,12,15 = 8 days)"


Now, we need to adjust number of billable days based on whether each
day is a weekday or a weekend.


In cells J1:J31, i have this formula:
=MID($F$22,IFERROR(FIND(CHAR(150),SUBSTITUTE($F$22 ,",",CHAR(150),ROW()-1))
+1,1),FIND(CHAR(150),SUBSTITUTE($F$22,",",CHAR(150 ),ROW()))-IFERROR(FIND(CH**AR(150),
SUBSTITUTE($F$22,",",CHAR(150),ROW()-1))+1,1))


This extracts each number (1,2,3,6,9,10,12,15).
Now, in the main portion of the invoice I have these two array
formulas:
=NETWORKDAYS(B22,D22)-SUM(IFERROR(--(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J**31),2)<6) ,""))&"
Weekdays (10hrs per day)"
and
=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IFERROR(--(WEEKDAY(DATE(YEAR(B22),MON**TH(B22),J1:J31),2)5) ,""))&"
Weekends (16hrs per day)"


My question is: can I do this somehow without using the helper column
(J)?
I couldn't think of another way to find each subsequent comma, perhaps
there is a more clever way of using the SUBSTITUTE function?


I would like this to be a template that anyone can use, and have to do
nothing besides fill in the two dates and the non-service days.
While it's not a problem hiding the J column, there's still a chance it
might get deleted or rows inserted to screw up the calculation.- Hide
quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default separate cell values with formulas - can this be improved?

You can eliminate the helper column but the resulting formula becomes kind
of long. Also, I see you're not using the Holidays argument to NETWOKDAYS.
If you needed to account for holidays this might push things over the edge!

Both are array formulas:

=NETWORKDAYS(B22,D22)-SUM(IF(ISNUMBER(FIND(","&DAY(ROW(INDIRECT(B22&":"& D22))),","&F22)),IF(WEEKDAY(ROW(INDIRECT(B22&":"&D 22)),2)<6,1)))&"
Weekdays(10hrs per day)"

=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IF(ISNUMBER(FIND(","&DAY(ROW(INDIRECT(B22&":"& D22))),","&F22)),IF(WEEKDAY(ROW(INDIRECT(B22&":"&D 22)),2)5,1)))&"
Weekends(16hrs per day)"


--
Biff
Microsoft Excel MVP


"ilia" wrote in message
oups.com...
OK, bear with me because this is kind of obfuscated.

I am working with a monthly invoice. On the invoice, we have Period
Start and Period End date. These will usually be first and last of
the month. We are billing for a service whose rate varies based on
whether it is a weekend or a weekday. We receive information from
service department regarding which days services were not performed,
and list them on the invoice.

Here's an example (without the " "s):

(stored as dates)
B22 = July 1, 2007
D22 = July 31, 2007
(text entries)
E22 = "(Off on July "
F22 = "1,2,3,6,9,10,12,15 = 8 days)"

Now, we need to adjust number of billable days based on whether each
day is a weekday or a weekend.

In cells J1:J31, i have this formula: =MID($F
$22,IFERROR(FIND(CHAR(150),SUBSTITUTE($F$22,",",CH AR(150),ROW()-1))
+1,1),FIND(CHAR(150),SUBSTITUTE($F$22,",",CHAR(150 ),ROW()))-
IFERROR(FIND(CHAR(150),SUBSTITUTE($F$22,",",CHAR(1 50),ROW()-1))+1,1))

This extracts each number (1,2,3,6,9,10,12,15). Now, in the main
portion of the invoice I have these two array formulas:

=NETWORKDAYS(B22,D22)-SUM(IFERROR(--
(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J31),2)<6)," "))&" Weekdays
(10hrs per day)"

and

=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IFERROR(--
(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J31),2)5)," "))&" Weekends
(16hrs per day)"

My question is: can I do this somehow without using the helper column
(J)? I couldn't think of another way to find each subsequent comma,
perhaps there is a more clever way of using the SUBSTITUTE function?

I would like this to be a template that anyone can use, and have to do
nothing besides fill in the two dates and the non-service days. While
it's not a problem hiding the J column, there's still a chance it
might get deleted or rows inserted to screw up the calculation.



  #9   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default separate cell values with formulas - can this be improved?

Or, you can use these non-array versions (normally entered):

=NETWORKDAYS(B22,D22)-SUMPRODUCT(--(ISNUMBER(FIND(","&DAY(ROW(INDIRECT(B22&":"&D22))) ,","&F22))),--(WEEKDAY(ROW(INDIRECT(B22&":"&D22)),2)<6))&"
Weekdays(10hrs per day)"

=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUMPRODUCT(--(ISNUMBER(FIND(","&DAY(ROW(INDIRECT(B22&":"&D22))) ,","&F22))),--(WEEKDAY(ROW(INDIRECT(B22&":"&D22)),2)5))&"
Weekends(16hrs per day)"

--
Biff
Microsoft Excel MVP


"T. Valko" wrote in message
...
You can eliminate the helper column but the resulting formula becomes kind
of long. Also, I see you're not using the Holidays argument to NETWOKDAYS.
If you needed to account for holidays this might push things over the
edge!

Both are array formulas:

=NETWORKDAYS(B22,D22)-SUM(IF(ISNUMBER(FIND(","&DAY(ROW(INDIRECT(B22&":"& D22))),","&F22)),IF(WEEKDAY(ROW(INDIRECT(B22&":"&D 22)),2)<6,1)))&"
Weekdays(10hrs per day)"

=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IF(ISNUMBER(FIND(","&DAY(ROW(INDIRECT(B22&":"& D22))),","&F22)),IF(WEEKDAY(ROW(INDIRECT(B22&":"&D 22)),2)5,1)))&"
Weekends(16hrs per day)"


--
Biff
Microsoft Excel MVP


"ilia" wrote in message
oups.com...
OK, bear with me because this is kind of obfuscated.

I am working with a monthly invoice. On the invoice, we have Period
Start and Period End date. These will usually be first and last of
the month. We are billing for a service whose rate varies based on
whether it is a weekend or a weekday. We receive information from
service department regarding which days services were not performed,
and list them on the invoice.

Here's an example (without the " "s):

(stored as dates)
B22 = July 1, 2007
D22 = July 31, 2007
(text entries)
E22 = "(Off on July "
F22 = "1,2,3,6,9,10,12,15 = 8 days)"

Now, we need to adjust number of billable days based on whether each
day is a weekday or a weekend.

In cells J1:J31, i have this formula: =MID($F
$22,IFERROR(FIND(CHAR(150),SUBSTITUTE($F$22,",",CH AR(150),ROW()-1))
+1,1),FIND(CHAR(150),SUBSTITUTE($F$22,",",CHAR(150 ),ROW()))-
IFERROR(FIND(CHAR(150),SUBSTITUTE($F$22,",",CHAR(1 50),ROW()-1))+1,1))

This extracts each number (1,2,3,6,9,10,12,15). Now, in the main
portion of the invoice I have these two array formulas:

=NETWORKDAYS(B22,D22)-SUM(IFERROR(--
(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J31),2)<6)," "))&" Weekdays
(10hrs per day)"

and

=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IFERROR(--
(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J31),2)5)," "))&" Weekends
(16hrs per day)"

My question is: can I do this somehow without using the helper column
(J)? I couldn't think of another way to find each subsequent comma,
perhaps there is a more clever way of using the SUBSTITUTE function?

I would like this to be a template that anyone can use, and have to do
nothing besides fill in the two dates and the non-service days. While
it's not a problem hiding the J column, there's still a chance it
might get deleted or rows inserted to screw up the calculation.





  #10   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 434
Default separate cell values with formulas - can this be improved?

hi, Biff !

I need to offer an excuse
your solution is simply perfect
I understood the post in a mistaken way

regards,
hector.




  #11   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 733
Default separate cell values with formulas - can this be improved?

"T. Valko" wrote...
Or, you can use these non-array versions (normally entered):

=NETWORKDAYS(B22,D22)-SUMPRODUCT(--(ISNUMBER(FIND(","
&DAY(ROW(INDIRECT(B22&":"&D22))),","&F22))),
--(WEEKDAY(ROW(INDIRECT(B22&":"&D22)),2)<6))
&" Weekdays(10hrs per day)"

=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUMPRODUCT(--(ISNUMBER(FIND(","
&DAY(ROW(INDIRECT(B22&":"&D22))),","&F22))),
--(WEEKDAY(ROW(INDIRECT(B22&":"&D22)),2)5))
&" Weekends(16hrs per day)"

....

Try F22: 11 = 1 days)

in which case the formulas above will match 1 and 11 and return

21 Weekdays(10hrs per day)
8 Weekends(16hrs per day)

rather than the correct

21 Weekdays(10hrs per day)
9 Weekends(16hrs per day)

You need ending commas too. And you could avoid array entry and
volatile functions with

=SUMPRODUCT((ISERR(FIND(","&DAY(ROW(INDEX($1:$6553 6,B22,1)
:INDEX($1:$65536,D22,1)))&",",","&SUBSTITUTE(F22," =",","))))
*(WEEKDAY(ROW(INDEX($1:$65536,B22,1):INDEX($1:$655 36,D22,1)),2)<6))
&" Weekdays (10hrs per day)"

=SUMPRODUCT((ISERR(FIND(","&DAY(ROW(INDEX($1:$6553 6,B22,1)
:INDEX($1:$65536,D22,1)))&",",","&SUBSTITUTE(F22," =",","))))
*(WEEKDAY(ROW(INDEX($1:$65536,B22,1):INDEX($1:$655 36,D22,1)),2)5))
&" Weekend Days (16hrs per day)"

  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default separate cell values with formulas - can this be improved?

"Harlan Grove" wrote in message
ups.com...
"T. Valko" wrote...
Or, you can use these non-array versions (normally entered):

=NETWORKDAYS(B22,D22)-SUMPRODUCT(--(ISNUMBER(FIND(","
&DAY(ROW(INDIRECT(B22&":"&D22))),","&F22))),
--(WEEKDAY(ROW(INDIRECT(B22&":"&D22)),2)<6))
&" Weekdays(10hrs per day)"

=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUMPRODUCT(--(ISNUMBER(FIND(","
&DAY(ROW(INDIRECT(B22&":"&D22))),","&F22))),
--(WEEKDAY(ROW(INDIRECT(B22&":"&D22)),2)5))
&" Weekends(16hrs per day)"

...

Try F22: 11 = 1 days)

in which case the formulas above will match 1 and 11 and return

21 Weekdays(10hrs per day)
8 Weekends(16hrs per day)

rather than the correct

21 Weekdays(10hrs per day)
9 Weekends(16hrs per day)

You need ending commas too. And you could avoid array entry and
volatile functions with

=SUMPRODUCT((ISERR(FIND(","&DAY(ROW(INDEX($1:$6553 6,B22,1)
:INDEX($1:$65536,D22,1)))&",",","&SUBSTITUTE(F22," =",","))))
*(WEEKDAY(ROW(INDEX($1:$65536,B22,1):INDEX($1:$655 36,D22,1)),2)<6))
&" Weekdays (10hrs per day)"

=SUMPRODUCT((ISERR(FIND(","&DAY(ROW(INDEX($1:$6553 6,B22,1)
:INDEX($1:$65536,D22,1)))&",",","&SUBSTITUTE(F22," =",","))))
*(WEEKDAY(ROW(INDEX($1:$65536,B22,1):INDEX($1:$655 36,D22,1)),2)5))
&" Weekend Days (16hrs per day)"


Yeah, I found my bug and made corrections/suggestions for it in the other
branch of this thread. I also thought about using ROW(INDEX rather than
ROW(INDIRECT.

The OP seems to have things under control but I was also thinking of
replacing ","&F22 with ","&LEFT(F22,FIND(" ",F22)-1)&"," but I like your use
of SUBSTITUTE.

--
Biff
Microsoft Excel MVP


  #13   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 733
Default separate cell values with formulas - can this be improved?

"T. Valko" wrote...
....
. . . but I was also thinking of replacing ","&F22 with
","&LEFT(F22,FIND(" ",F22)-1)&"," but I like your use of SUBSTITUTE.


Thanks, but there should probably be another SUBSTITUTE call to guard
against irregular spaces.

FIND(","&DAY(ROW(INDEX($1:$65536,B22,1)
:INDEX($1:$65536,D22,1)))&",",
","&SUBSTITUTE(SUBSTITUTE(F22," ",""),"=",","))

  #14   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 733
Default separate cell values with formulas - can this be improved?

"T. Valko" wrote...
....
. . . but I was also thinking of replacing ","&F22 with
","&LEFT(F22,FIND(" ",F22)-1)&"," but I like your use of SUBSTITUTE.


Thanks, but there should probably be another SUBSTITUTE call to guard
against irregular spaces.

FIND(","&DAY(ROW(INDEX($1:$65536,B22,1)
:INDEX($1:$65536,D22,1)))&",",
","&SUBSTITUTE(SUBSTITUTE(F22," ",""),"=",","))

  #15   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 15,768
Default separate cell values with formulas - can this be improved?

"Harlan Grove" wrote in message
ups.com...
"T. Valko" wrote...
Or, you can use these non-array versions (normally entered):

=NETWORKDAYS(B22,D22)-SUMPRODUCT(--(ISNUMBER(FIND(","
&DAY(ROW(INDIRECT(B22&":"&D22))),","&F22))),
--(WEEKDAY(ROW(INDIRECT(B22&":"&D22)),2)<6))
&" Weekdays(10hrs per day)"

=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUMPRODUCT(--(ISNUMBER(FIND(","
&DAY(ROW(INDIRECT(B22&":"&D22))),","&F22))),
--(WEEKDAY(ROW(INDIRECT(B22&":"&D22)),2)5))
&" Weekends(16hrs per day)"

...

Try F22: 11 = 1 days)

in which case the formulas above will match 1 and 11 and return

21 Weekdays(10hrs per day)
8 Weekends(16hrs per day)

rather than the correct

21 Weekdays(10hrs per day)
9 Weekends(16hrs per day)

You need ending commas too. And you could avoid array entry and
volatile functions with

=SUMPRODUCT((ISERR(FIND(","&DAY(ROW(INDEX($1:$6553 6,B22,1)
:INDEX($1:$65536,D22,1)))&",",","&SUBSTITUTE(F22," =",","))))
*(WEEKDAY(ROW(INDEX($1:$65536,B22,1):INDEX($1:$655 36,D22,1)),2)<6))
&" Weekdays (10hrs per day)"

=SUMPRODUCT((ISERR(FIND(","&DAY(ROW(INDEX($1:$6553 6,B22,1)
:INDEX($1:$65536,D22,1)))&",",","&SUBSTITUTE(F22," =",","))))
*(WEEKDAY(ROW(INDEX($1:$65536,B22,1):INDEX($1:$655 36,D22,1)),2)5))
&" Weekend Days (16hrs per day)"


Yeah, I found my bug and made corrections/suggestions for it in the other
branch of this thread. I also thought about using ROW(INDEX rather than
ROW(INDIRECT.

The OP seems to have things under control but I was also thinking of
replacing ","&F22 with ","&LEFT(F22,FIND(" ",F22)-1)&"," but I like your use
of SUBSTITUTE.

--
Biff
Microsoft Excel MVP




  #16   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 733
Default separate cell values with formulas - can this be improved?

"T. Valko" wrote...
Or, you can use these non-array versions (normally entered):

=NETWORKDAYS(B22,D22)-SUMPRODUCT(--(ISNUMBER(FIND(","
&DAY(ROW(INDIRECT(B22&":"&D22))),","&F22))),
--(WEEKDAY(ROW(INDIRECT(B22&":"&D22)),2)<6))
&" Weekdays(10hrs per day)"

=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUMPRODUCT(--(ISNUMBER(FIND(","
&DAY(ROW(INDIRECT(B22&":"&D22))),","&F22))),
--(WEEKDAY(ROW(INDIRECT(B22&":"&D22)),2)5))
&" Weekends(16hrs per day)"

....

Try F22: 11 = 1 days)

in which case the formulas above will match 1 and 11 and return

21 Weekdays(10hrs per day)
8 Weekends(16hrs per day)

rather than the correct

21 Weekdays(10hrs per day)
9 Weekends(16hrs per day)

You need ending commas too. And you could avoid array entry and
volatile functions with

=SUMPRODUCT((ISERR(FIND(","&DAY(ROW(INDEX($1:$6553 6,B22,1)
:INDEX($1:$65536,D22,1)))&",",","&SUBSTITUTE(F22," =",","))))
*(WEEKDAY(ROW(INDEX($1:$65536,B22,1):INDEX($1:$655 36,D22,1)),2)<6))
&" Weekdays (10hrs per day)"

=SUMPRODUCT((ISERR(FIND(","&DAY(ROW(INDEX($1:$6553 6,B22,1)
:INDEX($1:$65536,D22,1)))&",",","&SUBSTITUTE(F22," =",","))))
*(WEEKDAY(ROW(INDEX($1:$65536,B22,1):INDEX($1:$655 36,D22,1)),2)5))
&" Weekend Days (16hrs per day)"

  #17   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 434
Default separate cell values with formulas - can this be improved?

hi, guys !

there is someting inaccurate in both formulae (OP & Biff) -?-
as OP says... there are only 8 *total* days: - F22 = "1,2,3,6,9,10,12,15 = 8 days)"

Both formulae returns 22 *weekdays* -?-

Biff's formula returns only 1 weekend...
I guess it's missing day 1 -Sunday- because is not being preceeded by comma -?-

IF, we add to $F$22 one more weekday and one more weekend...
- F22 = "1,2,3,6,9,10,12,15,19,21 = 10 days)"

both formulae continues returning 22 *weekdays*

OP's formula returns 0 weekends
Biff's formula returns -1 weekend

[something is still missing] :-(

regards,
hector.

__ previous posts __
T. Valko wrote in message ...
You can eliminate the helper column but the resulting formula becomes kind of long.
Also, I see you're not using the Holidays argument to NETWOKDAYS.
If you needed to account for holidays this might push things over the edge!

Both are array formulas:

=NETWORKDAYS(B22,D22)-SUM(IF(ISNUMBER(FIND(","&DAY(ROW(INDIRECT(B22&":"& D22))),","&F22)),IF(WEEKDAY(ROW(INDIRECT(B22&":"&D 22)),2)<6,1)))&" Weekdays(10hrs per day)"

=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IF(ISNUMBER(FIND(","&DAY(ROW(INDIRECT(B22&":"& D22))),","&F22)),IF(WEEKDAY(ROW(INDIRECT(B22&":"&D 22)),2)5,1)))&" Weekends(16hrs per day)"

--
Biff
Microsoft Excel MVP


ilia wrote in message ...
OK, bear with me because this is kind of obfuscated.

I am working with a monthly invoice. On the invoice, we have Period Start and Period End date.
These will usually be first and last of the month.
We are billing for a service whose rate varies based on whether it is a weekend or a weekday.
We receive information from service department regarding which days services were not performed, and list them on the invoice.

Here's an example (without the " "s):

(stored as dates)
B22 = July 1, 2007
D22 = July 31, 2007
(text entries)
E22 = "(Off on July "
F22 = "1,2,3,6,9,10,12,15 = 8 days)"

Now, we need to adjust number of billable days based on whether each day is a weekday or a weekend.

In cells J1:J31, i have this formula: =MID($F$22,IFERROR(FIND(CHAR(150),SUBSTITUTE($F$22 ,",",CHAR(150),ROW()-1))
+1,1),FIND(CHAR(150),SUBSTITUTE($F$22,",",CHAR(150 ),ROW()))-
IFERROR(FIND(CHAR(150),SUBSTITUTE($F$22,",",CHAR(1 50),ROW()-1))+1,1))

This extracts each number (1,2,3,6,9,10,12,15). Now, in the main portion of the invoice I have these two array formulas:

=NETWORKDAYS(B22,D22)-SUM(IFERROR(--(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J31),2)<6)," "))&" Weekdays
(10hrs per day)"

and

=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IFERROR(--(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J31),2)5)," "))&" Weekends
(16hrs per day)"

My question is: can I do this somehow without using the helper column (J)?
I couldn't think of another way to find each subsequent comma
perhaps there is a more clever way of using the SUBSTITUTE function?

I would like this to be a template that anyone can use, and have to do nothing besides fill in the two dates and the non-service days.
While it's not a problem hiding the J column, there's still a chance it might get deleted or rows inserted to screw up the calculation.



  #18   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 434
Default separate cell values with formulas - can this be improved?

hi [again], guys !

I apologize... i made a wrong translation of weekday function into networkday :-((

[but]... I'm still getting more days than *total* days stated in $F$22 cell -?-

regards,
hector.

Héctor Miguel wrote in message ...
hi, guys !

there is someting inaccurate in both formulae (OP & Biff) -?-
as OP says... there are only 8 *total* days: - F22 = "1,2,3,6,9,10,12,15 = 8 days)"

Both formulae returns 22 *weekdays* -?-

Biff's formula returns only 1 weekend...
I guess it's missing day 1 -Sunday- because is not being preceeded by comma -?-

IF, we add to $F$22 one more weekday and one more weekend...
- F22 = "1,2,3,6,9,10,12,15,19,21 = 10 days)"

both formulae continues returning 22 *weekdays*

OP's formula returns 0 weekends
Biff's formula returns -1 weekend

[something is still missing] :-(

regards,
hector.

__ previous posts __
T. Valko wrote in message ...
You can eliminate the helper column but the resulting formula becomes kind of long.
Also, I see you're not using the Holidays argument to NETWOKDAYS.
If you needed to account for holidays this might push things over the edge!

Both are array formulas:

=NETWORKDAYS(B22,D22)-SUM(IF(ISNUMBER(FIND(","&DAY(ROW(INDIRECT(B22&":"& D22))),","&F22)),IF(WEEKDAY(ROW(INDIRECT(B22&":"&D 22)),2)<6,1)))&" Weekdays(10hrs per day)"

=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IF(ISNUMBER(FIND(","&DAY(ROW(INDIRECT(B22&":"& D22))),","&F22)),IF(WEEKDAY(ROW(INDIRECT(B22&":"&D 22)),2)5,1)))&" Weekends(16hrs per day)"

--
Biff
Microsoft Excel MVP


ilia wrote in message ...
OK, bear with me because this is kind of obfuscated.

I am working with a monthly invoice. On the invoice, we have Period Start and Period End date.
These will usually be first and last of the month.
We are billing for a service whose rate varies based on whether it is a weekend or a weekday.
We receive information from service department regarding which days services were not performed, and list them on the invoice.

Here's an example (without the " "s):

(stored as dates)
B22 = July 1, 2007
D22 = July 31, 2007
(text entries)
E22 = "(Off on July "
F22 = "1,2,3,6,9,10,12,15 = 8 days)"

Now, we need to adjust number of billable days based on whether each day is a weekday or a weekend.

In cells J1:J31, i have this formula: =MID($F$22,IFERROR(FIND(CHAR(150),SUBSTITUTE($F$22 ,",",CHAR(150),ROW()-1))
+1,1),FIND(CHAR(150),SUBSTITUTE($F$22,",",CHAR(150 ),ROW()))-
IFERROR(FIND(CHAR(150),SUBSTITUTE($F$22,",",CHAR(1 50),ROW()-1))+1,1))

This extracts each number (1,2,3,6,9,10,12,15). Now, in the main portion of the invoice I have these two array formulas:

=NETWORKDAYS(B22,D22)-SUM(IFERROR(--(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J31),2)<6)," "))&" Weekdays
(10hrs per day)"

and

=(D22-B22)+1-NETWORKDAYS(B22,D22)-SUM(IFERROR(--(WEEKDAY(DATE(YEAR(B22),MONTH(B22),J1:J31),2)5)," "))&" Weekends
(16hrs per day)"

My question is: can I do this somehow without using the helper column (J)?
I couldn't think of another way to find each subsequent comma
perhaps there is a more clever way of using the SUBSTITUTE function?

I would like this to be a template that anyone can use, and have to do nothing besides fill in the two dates and the non-service days.
While it's not a problem hiding the J column, there's still a chance it might get deleted or rows inserted to screw up the calculation.





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
Insert a value in a cell based upon a comparison of cell values in 2 separate worksheets Doctorjones_md Excel Discussion (Misc queries) 7 June 8th 07 09:32 PM
Insert a value in a cell based upon a comparison of cell values in 2 separate worksheets Doctorjones_md Excel Worksheet Functions 7 June 8th 07 09:32 PM
Separate values in cell by delimiter JR Excel Discussion (Misc queries) 13 February 6th 07 05:56 PM
find a cell matching separate column and row values LQEngineer Excel Worksheet Functions 2 July 26th 06 07:10 AM
Copy cell values across separate sheets claytorm Excel Discussion (Misc queries) 3 June 27th 05 10:03 PM


All times are GMT +1. The time now is 11:54 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"