Attempting to use SCAN() to check if consecutive cells are equal.

Cubist

Well-known Member
Joined
Oct 5, 2023
Messages
811
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Book3
ABCDEFG
11216611
2
3ExpectedFALSEFALSEFALSETRUEFALSETRUE
4FormulaFALSEFALSEFALSEFALSEFALSEFALSE
Sheet4
Cell Formulas
RangeFormula
B4:G4B4=SCAN(A1,B1:G1,LAMBDA(a,b,a=b))
Dynamic array formulas.


I'm attempting to use SCAN() to check if consecutive cells are equal but it's not giving the expected result. Perhaps I'm misusing the function. Any thoughts?
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Thats because SCAN is including all of the previous values. If you change it to a+b, you will notice that it is summing everything previously. You can use this formula instead:

Excel Formula:
=DROP(A1:G1=OFFSET(A1:G1,,1),,-1)
 
Upvote 0
You cannot use scan like that. How about
Excel Formula:
=B1:G1=A1:F1
 
Upvote 0
Solution
Thats because SCAN is including all of the previous values. If you change it to a+b.
I was under the impression that SCAN acts as an iterator, not an accumulator.

Only when you specify a+b, then it is an accumulator.
 
Upvote 0
In your formula "a" starts off as the value in A1, it then becomes the result of a=b (in this case FALSE) so on the 2nd iteration a=b which is FALSE=C1
 
Upvote 0
Makes sense now. It acts as an accumulator in the sense that it stores the result of the prior iterations. Thanks.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
@Fluff , in your other post, you have used =SCAN(,....) where leaving the first parameter empty. What's the default value? Is it 0 or "" or it automatically detect based on the data type of the array (2nd) parameter?

When entering the function, the parameter assistance doesn't have the square brackets [] to indicate it's an optional parameter. I was surprised it didn't know an error for missing parameters.
 
Last edited:
Upvote 0
In that post the initial value is irrelevant as the array has a value in the first cell.
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,690
Members
449,117
Latest member
Aaagu

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