Avoiding commas in formula if no value exists

Challis

New Member
Joined
Oct 22, 2017
Messages
21
Hi guys,
I have this formula which matches two criteria and returns upto 4 values all in the same cell.
It works well and as i intended but one thing I'd like to address is only putting commas in if a trailing value is returned.
So my question is, if no value is returned, is there a way to not show the trailing comma.
So say for example if one value was returned "A" it would just show "A". If two values were returned "A" & "B"" it would show "A,B".

Code:
=IFERROR(INDEX(Schedule!C:C,SMALL(IF((Schedule!$P$6:$P$1000=Dashboard!$A3)*(Schedule!$S$6:$S$1000={"Inspecting","Authoring Report"}),ROW(Schedule!$C$6:$C$1000)),ROWS(C$2:C$2))),"")&", "&IFERROR(INDEX(Schedule!C:C,SMALL(IF((Schedule!$P$6:$P$1000=Dashboard!$A3)*(Schedule!$S$6:$S$1000={"Inspecting","Authoring Report"}),ROW(Schedule!$C$6:$C$1000)),ROWS(C$2:C$3))),"")&", "&IFERROR(INDEX(Schedule!C:C,SMALL(IF((Schedule!$P$6:$P$1000=Dashboard!$A3)*(Schedule!$S$6:$S$1000={"Inspecting","Authoring Report"}),ROW(Schedule!$C$6:$C$1000)),ROWS(C$2:C$4))),"")&", "&IFERROR(INDEX(Schedule!C:C,SMALL(IF((Schedule!$P$6:$P$1000=Dashboard!$A3)*(Schedule!$S$6:$S$1000={"Inspecting","Authoring Report"}),ROW(Schedule!$C$6:$C$1000)),ROWS(C$2:C$5))),"")

Thanks
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
Hi,

Can you show various sample results from the formula that contain the unwanted , commas?
 
Upvote 0
Maybe...(untested)
Use a space as separator rather than ", " and try
=SUBSTITUTE(TRIM(formula here)," ",", ")

Hope this helps

M.
 
Last edited:
Upvote 0
The above formula doesn't work properly with the values returned by the INDEX functions contain spaces.
Maybe something like this
=SUBSTITUTE(IFERROR(", "&INDEX(.....),"")&IFERROR(", "&INDEX(.....),"")&IFERROR(", "&INDEX(.....),"")&IFERROR(", "&INDEX(.....),""),", ","",1)

M.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,179
Members
453,021
Latest member
Justyna P

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