You can perform basic string interpolation in Google Sheets using a combination of functions such as CONCATENATE, & operator, and TEXTJOIN. These functions allow you to combine text strings, variables, and expressions to create a new string that includes variable values.
The & operator is a straightforward way to concatenate (or combine) text strings and values. For example, if you have a person's first and last name in separate cells and you want to combine them in a full name format, you could use the & operator like this:
=A1 & " " & B1
For example, if A1 contains "John" and B1 contains "Doe", the result would be "John Doe".
The CONCATENATE function is another way to join together text items. The syntax is:
=CONCATENATE(text1, [text2, ...])
For example:
=CONCATENATE(A1, " ", B1)
This should produce the same result as the example above.
The TEXTJOIN function provides more flexibility and is particularly useful when you want to include a delimiter that should only appear between text items that are not empty. The syntax is:
=TEXTJOIN(delimiter, ignore_empty, text1, [text2, ...])
For example, if you want to join several strings but only include commas between them if they are not empty, you could use:
=TEXTJOIN(", ", TRUE, A1, B1, C1)
This formula would join the text in A1, B1, and C1, separating them with a comma and a space, but only if the cells are not empty.
Below is an example:
While Google Sheets does not natively support string interpolation, the combination of basic concatenation functions offers a way to dynamically construct strings based on the contents of other cells in Google Sheets.
We hope that this article has helped you and given you a better understanding of how to do string interpolation in Google Sheets. If you enjoyed this article, you might also like our articles on how to use vertical align in Google Sheets and how to compare two columns in Google Sheets.