Search code examples
google-sheetsgoogle-sheets-formula

How to Increment Multiple Numbers in a Sting?


I am checking to see if two numbers match and if so just repeate a sting of numbers, if they dont not match i want to return the sting with all numbers incremented by 1.

=IF(AND(M5<>"",V5<>L5),M5, [increment the numbers] )

Given that: M5= 9,8,7 V5 does equal L5

I want the output to be: 10,9,8


Solution

  • It would be this

    =ArrayFormula(IF(AND(M5<>"",V5<>L5),M5, textjoin(",",,split(M5,",")+1)))
    

    enter image description here

    But note that it would try to split M5 if M5 is blank (giving an error) or V5=L5 so maybe try

    =ArrayFormula(IF(AND(M5<>"",V5=L5),textjoin(",",,split(M5,",")+1),M5))