Google-sheets – RegexReplace produces an error

google sheetsregex

I have two sheets of data as per below:

╔═══════════╦══════╦══════════════╗
║ SheetName ║ Cell ║  CellValue   ║
╠═══════════╬══════╬══════════════╣
║ Sheet1    ║ B1   ║ ='sheet2'!A2 ║
║ Sheet2    ║ A2   ║ 0576543 ABC  ║
╚═══════════╩══════╩══════════════╝

This produces the output 0576543 ABC in B1

I want the value in B1 to replace the text after the space with xxx.

The value in B1 should be 0576543 xxx.

I have tried this Regex but it produces an error.

=REGEXREPLACE("'sheet2'!A2", " .*", "xxx")

Where am I going wrong?

Best Answer

The issue in this case appears to be that you put double quotes and single quotes around the cell reference, try this, should fix it.

=REGEXREPLACE(sheet2!A2, " .*", "xxx")