Dynamic Array - Remove Subsequent Instances

Cubist

Well-known Member
Joined
Oct 5, 2023
Messages
2,139
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Suppose I have an array in column A, I want to remove subsequent repeated elements; only keeping the first. For subsequent instances, replace with "". The result should be an array. UNIQUE() doesn't work because I want to keep the same index.
Book1
AB
1FromTo
2AA
3
4BB
5
6B
7B
8CC
9C
10
11
12
13C
Sheet6
Cell Formulas
RangeFormula
A2:A13A2={"A";" ";"B";" ";"B";"B";"C";"C";" ";"";"";"C"}
B2:B13B2={"A";" ";"B";" ";"";"";"C";"";" ";"";"";""}
Dynamic array formulas.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
another solution for your reference:
工作簿1
ABC
1FromTo
2AA
3
4BB
5
6B
7B
8CC
9C
10
11
12
13C
14
Sheet1
Cell Formulas
RangeFormula
A2:A13A2={"A";" ";"B";" ";"B";"B";"C";"C";" ";"";"";"C"}
B2:B13B2=MAP(A2#,LAMBDA(x,REPT(x,COUNTIF(A2:x,x)=1)))
Dynamic array formulas.
 
Upvote 0
Hi

Option to use the reference..
=MAP(A2#,LAMBDA(x,REPT(x,COUNTIF((@A2#):x,x)=1)))
 
Upvote 0
Thanks for all the options. They all seem to work on my test data. I'll give Alex credit for the first solution.
 
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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