Combine cells conditionally

tigerzen

Board Regular
Joined
Mar 8, 2023
Messages
165
Office Version
  1. 365
Platform
  1. Windows
Book4
ABC
2Tom Tom
3JonesJones Tom
4FrancisNext 
5AlbertAlbert
6JohnJohn Albert
7SinatraSinatra John Albert
8PeterNext 
9StevenSteven
10TownsendTownsend Steven
11MichaelNext 
12VV
13JacksonJackson V
14
15Desired
16Tom
17JonesTom Jones
18FrancisNext
19Albert
20John
21SinatraFrancis Albert John Sinatra
22PeterNext
23Steven
24TownsendPeter Steven Townsend
25MichaelNext
26V
27JacksonMichael V Jackson
Sheet3
Cell Formulas
RangeFormula
C2:C13C2=IF(B2="",A2&" "&C1,"")

Data is received as per attached information. Column C indicates what needs to happen, I have attempted a solution which doesn't work, it is incomplete and returns the name in the wrong order. Looking for a formula here that will do the job, please note that I'm assisting someone who only has Excel 2016 thus no Textjoin function which may or may not impact on the solution.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Do you mean this?
1683092651954.png

Note: C1 formula would be =If(B1="",A1,"")
 
Upvote 0
Hi Nemmi69, that is close but it needs to be in the desired format in my first post and it must contain the first entry eg Francis Albert John Sinatra rather than just Albert John Sinatra. Also the Albert, Albert John should not be part of the final output although I suppose they can be filtered out at the end.
 
Upvote 0
Upvote 0
Hi Peter, that is indeed the solution however I need to come up with a formula that will work on an older version of Excel.
 
Upvote 0
Older version do not lend themselves to text joining functions very well. Perhaps you could use what I have in column C or columns C & D below.
If you want the results shown in column D but without the helper column then I think that you will need to use vba. If that would be better for you then post back to say so.

Cell Formulas
RangeFormula
C1C1=A1
D1:D12D1=IF(OR(B2="Next",A2=""),C1,"")
C2:C12C2=IF(B2="Next",A2,C1&" "&A2)
 
Upvote 0
Solution
you can use CONCATENATE back to 2007 (Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 Excel Starter 2010)

1683102488350.png
 

Attachments

  • 1683102407350.png
    1683102407350.png
    42.2 KB · Views: 4
Upvote 0
you can use CONCATENATE back to 2007 (Excel for Microsoft 365 Excel for Microsoft 365 for Mac Excel for the web Excel 2021 Excel 2021 for Mac Excel 2019 Excel 2019 for Mac Excel 2016 Excel 2016 for Mac Excel 2013 Excel 2010 Excel 2007 Excel for Mac 2011 Excel Starter 2010)
Your latest formula still does not produce the results that the OP has listed under "Desired" in post #1
 
Upvote 0
So from Peter SSs formula

1683114552595.png

Change C2 to =IF(B2="Next", A2, CONCATENATE(C1, " ",A2)). Then drag down
 
Upvote 0

Forum statistics

Threads
1,215,214
Messages
6,123,665
Members
449,114
Latest member
aides

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