Copy formula to non-blank cells in table and concatenate results

nevjones

New Member
Joined
Jun 14, 2011
Messages
12
Hi All,
Below is an extract of a table of data I currently have which in reality is much larger with 54 risks and 90 funds across the top.

[TABLE="width: 713"]
<tbody>[TR]
[TD][/TD]
[TD]Fund A[/TD]
[TD]Fund B[/TD]
[TD]Fund C[/TD]
[TD]Fund D[/TD]
[TD]Fund E[/TD]
[/TR]
[TR]
[TD] Risk_01_RT[/TD]
[TD]X[/TD]
[TD]X[/TD]
[TD]X[/TD]
[TD]X[/TD]
[TD]X[/TD]
[/TR]
[TR]
[TD] Risk_02_RT[/TD]
[TD][/TD]
[TD]X[/TD]
[TD]X[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD] Risk_03_RT[/TD]
[TD]X[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD] Risk_04_RT[/TD]
[TD][/TD]
[TD]X[/TD]
[TD]X[/TD]
[TD]X[/TD]
[TD][/TD]
[/TR]
[TR]
[TD] Risk_05_RT[/TD]
[TD]X[/TD]
[TD][/TD]
[TD]X[/TD]
[TD]X[/TD]
[TD]X[/TD]
[/TR]
[TR]
[TD]Result[/TD]
[TD]01,03,05[/TD]
[TD]01,02,04[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

I need to replace the X's with the risk number which I can do by using the mid function but as the table is so large is there a quick way of doing this in VBA instead of filtering by each fund and copying the formula down.

Also I need to concatenate the risk numbers to send to our developers with a comma in-between as shown in the example result for Funds A & B.

Thanks in advance!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I am not able to help you with VBA to replace all the X's with their numbers. But I can concatenate with a comma the results in each column by using the Excel 2016 function TEXTJOIN.

I added an extra column to extract the risk numbers and make things easier. Copy B2 down and C7 across.


Book1
ABCDEFG
1RiskRisk NumberFund AFund BFund CFund DFund E
2Risk_01_RT01XXXXX
3Risk_02_RT02XX
4Risk_03_RT03X
5Risk_04_RT04XXX
6Risk_05_RT05XXXX
7Concatenated Risks:01, 03, 0501, 02, 0401, 02, 04, 0501, 04, 0501, 05
Sheet50
Cell Formulas
RangeFormula
B2=MID(A2,6,2)
C7{=TEXTJOIN(", ",1,IF(NOT(ISBLANK(C2:C6)),$B$2:$B$6,""))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
That's great, thanks for your reply and help, much appreciated. It worked well and I've learnt a new function, saved me load of time.
Have a good weekend!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,182
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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