Combine cells conditionally on the way down when cell content changes

inosent

Board Regular
Joined
Mar 19, 2007
Messages
131
The best way to describe this is by an example:

Row A

1- O
2- 1
3- 2
4- 3
5- R
6- 1
7- 2
8- B
9- 5
10 -6

What I am looking for is a formula I can fill down in Row B where the result will look like this:

O
O - 1
O - 2
O - 3
R
R - 1
R - 2
B
B - 5
B - 6

So when there is a letter in A1, as long as the next row does not contains that letter, then the next row will combine A1 with A2 in B2; A1 with A3 in B3; A1 with A4 in B4; but since A5 has a new letter, B5 will equal A5, then after, A5 with A6 in B6; A5 with A7 in B7 and so on
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Copy the formula in B1 down to the end of col A data.
Excel Workbook
AB
1O 
211
322
433
5R
611
722
8B
955
1066
Sheet4
 
Upvote 0
Thanks, but that is not what I am looking for. Maybe my example is not good enough.

Let's try this

Col A -------------------B
R1 Abstract
R2 --------------------fun
R3 ---------------------43yrt
R4 Health
R5 ----------------------early
R6 ----------------------1

So as long as there are no new values in A:

C1 = "Abstract"
C2 = "Abstract - Fun"
C3 = "Abstract - 43yrt"
C4 = "Health"
C5 = "Health - early"
C6 = "Health - 1"

What I want is for col A to act as the main category, and the values in col b to be the sub-values, and when the value in Col A changes, that becomes the new main category, and the values in Col B become the associated sub-values for the new main category.

And, so, in my new example, every time the value in A changes (with blank cells in between the change of values in Col A, doesn't matter if they are text or numbers), the formula in Col C (in htis new example) will change with it, and associate that value with the subsequent rows in Col B, until the value in A changes again.






Copy the formula in B1 down to the end of col A data.
Excel Workbook
AB
1O 
211
322
433
5R
611
722
8B
955
1066
Sheet4
 
Upvote 0
[Table="width:, class:grid"][tr][td]Row\Col[/td][td]
A​
[/td][td]
B​
[/td][td]
C​
[/td][/tr][tr][td]
1​
[/td][td]Abstract[/td][td][/td][td] Abstract[/td][/tr]
[tr][td]
2​
[/td][td][/td][td]fun[/td][td] Abstract - Fun[/td][/tr]
[tr][td]
3​
[/td][td][/td][td]43yrt[/td][td] Abstract - 43yrt[/td][/tr]
[tr][td]
4​
[/td][td]Health[/td][td][/td][td] Health[/td][/tr]
[tr][td]
5​
[/td][td][/td][td]early[/td][td] Health - early[/td][/tr]
[tr][td]
6​
[/td][td][/td][td]
1​
[/td][td] Health - 1[/td][/tr]
[/table]


In C1 enter and copy down:

=LOOKUP(REPT("z",255),$A$1:A1)&IF($B1="",""," - "&$B1)
 
Upvote 0

Forum statistics

Threads
1,224,832
Messages
6,181,235
Members
453,026
Latest member
cknader

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