Search code examples
google-sheets

Trying to combine words and math in a single cell in google sheets


I'm trying to combine words and math together into a single cell in google sheets. The error I'm getting "Formula Parse Error"

Here's what I've got:

="Replace "&(D2/5)"Boltguns with Astartes Grenade Launchers ("&((D2/5)/2)"Frag and "&((D2/5)/2)"Krack)"

Cell D2's Value is 30

What I want the cell to read as:

Replace 6 Boltguns with Astartes Grenade Launchers (3 Frag and 3 Krak)

I've tried using Qoutient, Product, and Sum functions to no avail.


Solution

  • You need to ensure that the text and the calculations are properly concatenated. The text values and the calculations have to be handled separately and concatenated with &s:

    ="Replace " & (D2/5) & " Boltguns with Astartes Grenade Launchers (" & (D2/5)/2 & " Frag and " & (D2/5)/2 & " Krak)"
    

    You could also improve on your formula to handle pluralization using an IF statement:

    ="Replace " & (D2/5) & IF((D2/5)=1, " Boltgun", " Boltguns") & " with Astartes Grenade Launchers (" & (D2/5)/2 & IF((D2/5)/2=1, " Frag", " Frags") & " and " & (D2/5)/2 & IF((D2/5)/2=1, " Krak", " Kraks") & ")"