Extract multiple substrings from within a string

alain2363

New Member
Joined
Feb 13, 2013
Messages
2
I have a tally sheet with field inputs of nurses working days. I need to separate # of week days and of weekend days. The sheet looks like this :
SiteNameDates in 2013
MULMK
05,12,19,26 Jan,

<tbody>
</tbody>
MULPN
21,26,27 Jan,

<tbody>
</tbody>
MULRM
29 Jan,

<tbody>
</tbody>

<tbody>
</tbody>







I did some cleaning first: TRIM(SUBSTITUTE(UPPER(C3),"JAN"," "))
I have tried different combinations of
* MID(<source>,FIND(",",<source>+1,2)
* MID(<source>,1,FIND(" ",<source>-1))

And proceed so forth step-by-step, but is there a better way (vba macro?) to get a result of separating the chain of days worked into individual dates and count the number of weekdays and of weekend days:

SiteNameDates in 2013WeekdaysWeekend Days
MULMK05,12,19,26 Jan,4
MULPN21,26,27 Jan,12
MULRM29 Jan,1

<tbody>
</tbody>











Thank you for anyone who comes with any idea, even partial ideas and I promise to post my findings for everyone to see. Tallies of this kind are used all over the place.

Alain
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
I have a tally sheet with field inputs of nurses working days. I need to separate # of week days and of weekend days. The sheet looks like this :
Site
Name
Dates in 2013
MUL
MK
05,12,19,26 Jan,

<TBODY>
</TBODY>
MUL
PN
21,26,27 Jan,

<TBODY>
</TBODY>
MUL
RM
29 Jan,

<TBODY>
</TBODY>

<TBODY>
</TBODY>







I did some cleaning first: TRIM(SUBSTITUTE(UPPER(C3),"JAN"," "))
I have tried different combinations of
* MID(<SOURCE>,FIND(",",<SOURCE>+1,2)
* MID(<SOURCE>,1,FIND(" ",<SOURCE>-1))

And proceed so forth step-by-step, but is there a better way (vba macro?) to get a result of separating the chain of days worked into individual dates and count the number of weekdays and of weekend days:

Site
Name
Dates in 2013
Weekdays
Weekend Days
MUL
MK
05,12,19,26 Jan,
4
MUL
PN
21,26,27 Jan,
1
2
MUL
RM
29 Jan,
1

<TBODY>
</TBODY>











Thank you for anyone who comes with any idea, even partial ideas and I promise to post my findings for everyone to see. Tallies of this kind are used all over the place.

Alain

Hello and welcome to MrExcel
D2 down
=SUMPRODUCT(--(LEN(F2:M2)>0))-E2
E2 down
=SUM(IF(ISNUMBER(F2:I2),IF(WEEKDAY(F2:I2)={1;7},1)))
Confirm Control+Shift+Enter
F2 down and accross
=IF(COLUMNS($C$2:C2)>LEN($C2)-LEN(SUBSTITUTE($C2,",","")),"",DATEVALUE(TRIM(MID(SUBSTITUTE(","&SUBSTITUTE($C2," ",","),",",REPT(" ",100)),COLUMNS($A$2:A2)*100,100))&SUBSTITUTE(RIGHT($C2,4),",","")&2013))
 
Upvote 0
Hello and welcome to MrExcel
D2 down
=SUMPRODUCT(--(LEN(F2:M2)>0))-E2
E2 down
=SUM(IF(ISNUMBER(F2:I2),IF(WEEKDAY(F2:I2)={1;7},1)))
Confirm Control+Shift+Enter
F2 down and accross
=IF(COLUMNS($C$2:C2)>LEN($C2)-LEN(SUBSTITUTE($C2,",","")),"",DATEVALUE(TRIM(MID(SUBSTITUTE(","&SUBSTITUTE($C2," ",","),",",REPT(" ",100)),COLUMNS($A$2:A2)*100,100))&SUBSTITUTE(RIGHT($C2,4),",","")&2013))

Robert, thank you for your formulaes which I am digesting slowly.
In my second tables of 4 Rows (1,2,3,4) and 5 Columns (A,B,C,D,E),
a) SUMPRODUCT( is for week days
b) SUM(IF(ISNUMBER is for weekend days
c) IF(COLUMNS($C$2:C2 is not being resolved, and i don't understand what it does yet
Could you clarify please.
 
Upvote 0
Robert, thank you for your formulaes which I am digesting slowly.
In my second tables of 4 Rows (1,2,3,4) and 5 Columns (A,B,C,D,E),
a) SUMPRODUCT( is for week days
b) SUM(IF(ISNUMBER is for weekend days
c) IF(COLUMNS($C$2:C2 is not being resolved, and i don't understand what it does yet
Could you clarify please.

a) Yes, but this just count of cell with no blank formula blank minus Weekend days
b)yes, this foromula create two ranges- one for Saurday and one for Sunday then SUM then up
c)As we going accross columns we need indication when the TRUE statment(long formula) should stop,
In first example as you go along in will stop at 4th column which is the number of comas in delivered by the LEN(.....formula)
 
Upvote 0

Forum statistics

Threads
1,215,014
Messages
6,122,697
Members
449,092
Latest member
snoom82

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