Concatenate cells if, values of another column are the same as above

McBee1989

New Member
Joined
Nov 1, 2016
Messages
14
Hi,
I am having a bit of trouble with a nested IF statement...

Basically, I want column G to concatenate with the rows above it, IF, the values in column A are the same above. The number of values in column A varies from 2 - 9 so the formula I currently have doesn't work (pasted below).

=IF(A3<>A2,G3,IF(A3=A2,G3&"|"&G2))

So that work's if the values in column A only appear twice. However, if the value in column A appears 6, 7, 8 etc times, it doesn't work. Obviously I dont want it to concatenate if the value in column A changes to a new number.

Any help is appreciated.

Thanks
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Special-K99

Well-known Member
Joined
Nov 7, 2006
Messages
8,426
Office Version
  1. 2019
You dont need the second IF

IF(A3<>A2 then G3 otherwise
A3 MUST equal A2 so no need to test it again with IF(A3=A2...

It should simply be

=IF(A3<>A2,G3,G3&"|"&G2)

or even

G3&IF(A3<>A2,"","|"&G2)

Obviously this doesnt solve your main problem but is an improvement on your existing formula
 
Last edited:

Forum statistics

Threads
1,171,733
Messages
5,877,177
Members
433,236
Latest member
Yelnats23

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
Top