Home > Back-end >  Regexmatch variable cell instead of ?2$
Regexmatch variable cell instead of ?2$

Time:07-16

I got the following formula:

  IF(ISBLANK(A1:A),,
   IF(
    REGEXMATCH(
     TO_TEXT(A1:A),
     "^(?i)[A-Z] ?2$"),
    "double",
    A1:A)))

Instead of only matching '2', I want it to match a specific cell. So that part should be something like: "^(?i)[A-Z] ? D1 $"),

How can I make this work?

CodePudding user response:

You can use this simpler formula for all your mentioned cases

=INDEX(IF(REGEXMATCH(A3:A10&" ","\D "&A1&" $|^"&A1&" $"), 
           "double",A3:A10))

enter image description here

(do adjust ranges and locale according to your needs)

(Also: please do NOT keep altering your original question as well as double posting)

CodePudding user response:

Replace 2 with "&D1&".

   IF(
    REGEXMATCH(
     TO_TEXT(A1:A),
     "^(?i)[A-Z] ?"&D1&"$"),
    "double",
    A1:A)))
  • Related