SUBSTITUTE and CHAR(10): if cell to right is blank don't want the CHAR(10)...

itr674

Well-known Member
Joined
Apr 10, 2002
Messages
1,786
Office Version
  1. 2016
Platform
  1. Windows
Using this formula to combine data from 6 columns. It works but if the cell to the right is blank, or 0, I don't want the last CHAR(10), but having trouble trying to figure out how to stop that...


SUBSTITUTE(
IF(B8=0,"","aa: "&B8&CHAR(10))&
IF(C8=0,"","bb: "&C8&CHAR(10))&
IF(D8=0,"","cc: "&D8&CHAR(10))&
IF(E8=0,"","dd: "&E8&CHAR(10))&
IF(F8=0,"","ee: "&F8&CHAR(10))&
IF(G8=0,"","ff: "&G8),"","")
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Not sure what you mean but maybe something like this ? (not tested !)
Code:
SUBSTITUTE(
IF(B8=0,"","aa: "&B8)&
IF(C8=0,"","bb: "&CHAR(10)&C8)&
IF(D8=0,"","cc: "&CHAR(10)&D8)&
IF(E8=0,"","dd: "&CHAR(10)&E8)&
IF(F8=0,"","ee: "&CHAR(10)&F8)&
IF(G8=0,"","ff: "&CHAR(10)&G8),"","")
<!-- / message -->
 
Upvote 0
Gerald Higgins, thank you . As I was searching for another solution today, I saw that I never thanked you.
 
Upvote 0

Forum statistics

Threads
1,212,933
Messages
6,110,759
Members
448,295
Latest member
Uzair Tahir Khan

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