Search code examples
functiongoogle-sheetsstring-concatenation

Automatically add standard strings either side of variable strings


I have a library of flags online that I use in a spreadsheet. The current function looks like this:

=image("http://www.website.com/images/Flags/us.png", 3)

I would like to apply a rule or a function to an entire column so that I just need to write us and it automatically adds this before:

=image("http://www.website.com/images/Flags/

and this after:

.png", 3)

Is this even possible?


Solution

  • Certainly. If you put the two 'standard components' into say B1 and C1 as shown below then:

    =B$1&A3&C$1  
    

    should serve to concatenate the three elements to suit provided the us is in A3. The formula can be copied down to wrap the standard components around other values in ColumnA, if required:

    SO14461482 example