79391994

Date: 2025-01-27 19:50:09
Score: 1
Natty:
Report link

I know you asked for a vba answer years ago; I'm putting this here because there's a better way to do it now with recursive lambda functions. Essentially just define a formula called "ConsecuCheck" in Name Manager as follows:

=LAMBDA(text,spot, IF(LEN(text)<spot, 0, IF(AND(MID(text, spot, 1)=MID(text, spot-1,1),MID(text, spot, 1)=MID(text, spot-2,1)),1, ConsecuCheck(text,spot+1))))

This works for 3 or more consecutive characters. The use would be "=ConsecuCheck(A1, 3)" The second parameter must be 3 (or higher, if you don't want to check the entire value for some reason). It returns a 1 if there are 3 consecutive characters which are the same.

Benefits: faster than VBA, do not have to ship macro-enabled excel files Drawbacks: not quite as flexible as a regex

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: S Campbell