On Google Sheets, I'm trying to use the text in one cell (say B4 contains: "Janet") and reference it in a sentence in another cell (say G4 is: "Hi {Enter B4 here}, I'm reaching out to you today...")
A little background: I have about 130 columns of data that contain websites, first name, email, and vendor type that I hope to reference in an out reach email that I just copy down across a series of columns.
Thanks for any help
You can use LEFT + SEARCH in Google Sheets to extract text from a string or to extract data that comes before a specific text. LEFT is used to return a specific number of characters from the leftmost cell's beginning. SEARCH looks for specific characters/strings and determines their position.
You can extract text from the left side of a cell in Excel by using the LEFT Function. Simply supply the text, and enter the number of characters to return.
You can do this with a formula and copy down:
="Hi "& B4 &", I'm reaching out to you today..."
Not sure if this is entirely what you want but this will do a replacement. It looks for a structure like this {{A2}} with a cell in A1Notation in the center. You must selected the cell with the text that you want to perform the replacement in.
function mergeReplace()
{
var re=/\{\{[A-Z]{1,2}\d{1,3}\}\}/g;
var ss=SpreadsheetApp.getActive();
var sht=ss.getSheetByName('Matches');
var rng=sht.getActiveRange();
var a1=rng.getA1Notation();
var s=rng.getValue();
var matches=s.match(re);
for(var i=0;i<matches.length;i++)
{
var r=matches[i].slice(2,-2);
s=s.replace(matches[i],sht.getRange(r).getValue());
}
rng.setValue(s);
}
Here's what my data looked like:
Before Replacement:
After Replacement:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With