I receive an excel spreadsheet from the managers with everyone's schedule. I
would like to automatically caculate how many hours each person works. Is
there a formula for this? I would like it caculate just the time.
I receive the information as follows
F1 G1
ALEX 10-7 RAMI 10-7
RAMI 11-8 CHAD 11-8
STEPHAN 10-7
This is pretty complicated. As Sandy intimated, it would be far, far better to
design a proper data input sheet.
If that is absolutely not possible, the following might work.
The following assumptions are made:
1. The format is as follows:
<NAME><space><StartTime><hyphen><EndTime>
2. There are no <space>'s in <NAME>.
Some format changes may be allowable, but we would have to know what they are.
Download and install Longre's free morefunc.xll add-in from
http://xcell05.free.fr/
List the names in a column someplace: e.g. A1:A4
ALEX
RAMI
CHAD
STEPHAN
Name the range where the information is stored "tbl"
Insert/Name/Define
**Array enter** the following formula in B1, and copy/drag down to B4. To
**array-enter** a formula, after typing or pasting the formula into the cell,
hold down <ctrl><shift> while hitting <enter>. Excel will place braces {...}
around the formula.
B1:
=SUM(IF(ISERR(-REGEX.MID(tbl,"(?<="&$A1&"\s)"&"\d+(?=-)")),0,
-REGEX.MID(tbl,"(?<="&$A1&"\s)"&"\d+(?=-)")+
REGEX.SUBSTITUTE(REGEX.MID(tbl,"(?<="&$A1&"\s)"&".*"),"(\d+-)")+
12*(---REGEX.SUBSTITUTE(REGEX.MID(tbl,"(?<="&$A1&"\s)"&".*"),"(\d+-)")
<--REGEX.MID(tbl,"(?<="&$A1&"\s)"&"\d+(?=-)"))))
--ron