title: Google sheets, Add text with different font sizes in one cell
body: <p>So I saw this other question on here that is very similar to what I need, but I need it a little different and I don't know what I need to change to do this.</p>
  <p><a href="https://stackoverflow.com/questions/62836792/google-sheets-two-font-sizes-one-cell">Google Sheets, Two Font Sizes One Cell</a> &lt; This is the link to the question.</p>
  <pre><code>function myFunction() {
    const sheetName = &quot;Sheet1&quot;;  // Please set the sheet name.
    
    const ss = SpreadsheetApp.getActiveSpreadsheet();
    const sheet = ss.getSheetByName(sheetName);
    const range = sheet.getRange(&quot;A1:A&quot; + sheet.getLastRow());
    const richTextValues = range.getRichTextValues().map(([a]) =&gt; {
      const text = a.getText();
      const pos = text.indexOf(&quot;|&quot;);
      if (pos &gt; -1) {
        const temp = a.getTextStyle(0, pos - 1);
        const textStyle = SpreadsheetApp.newTextStyle()
          .setFontSize(5)
          .setForegroundColor(&quot;red&quot;)
          .setItalic(true)
          .setBold(true)
          .build();
        return [
          SpreadsheetApp.newRichTextValue()
          .setText(text)
          .setTextStyle(0, pos - 1, temp)
          .setTextStyle(pos + 2, text.length, textStyle)
          .build()
        ];
      }
      return [SpreadsheetApp.newRichTextValue().setText(text).setTextStyle(a.getTextStyle()).build()];
    });
    range.setRichTextValues(richTextValues);
  }
  </code></pre>
  <p>^This is the code that answered the question to &quot;<em>Google Sheets, Two Font Sizes One Cell</em>&quot;</p>
  <p>this is what i need, (image below).</p>
  <p><a href="https://i.stack.imgur.com/cvfPp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cvfPp.png" alt="enter image description here" /></a></p>
  <p>In the &quot;Google Sheets, Two Font Sizes One Cell&quot; they have a dynamic setup where <code>NAME NAME</code> in <code>as is</code> might have red text so <code>desired</code> <code>NAME NAME</code> will also have red text. I dont want this. I want to take only the Value of the <code>Input</code>. The <code>Output</code> needs to have a set font for the <em>value</em> and <em>suffix</em>. I need the <code>value</code> font size to be <code>15</code>. And I need the <code>suffix</code> font size to be <code>8</code> and <code>italic</code>.</p>
  <p>I also need the <em>value</em> to be rounded. so say the value of &quot;miles per gal&quot; is <code>21.2021857923497</code> i need it rounded to <code>21.20</code>. The amount of zeros after the decimal show what i need it rounded to on the image above . But &quot;miles driven&quot; wont need to be rounded.</p>
  <p>The &quot;Input&quot; is going to be from a list of logs from one sheet and the &quot;Output&quot; is going to be a put in a separate sheet. (the calulated values are formulas i made)</p>
  <p><a href="https://i.stack.imgur.com/Pbq1S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pbq1S.png" alt="enter image description here" /></a>
  <a href="https://i.stack.imgur.com/zLmJ3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zLmJ3.png" alt="enter image description here" /></a></p>
  <p>I want to clarify this because i asked a very similar question a while ago about this and someone said to just seperate the <em>value</em> and <em>suffix</em> into 2 cells. the reason i dont want to do this is because in the context of where the &quot;Outputs&quot; are going to be, it has awkward spacing that I dont like. (example below)</p>
  <p><a href="https://i.stack.imgur.com/aHxj7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aHxj7.png" alt="enter image description here" /></a></p>
  <p>Sorry if im asking for alot, but it would be awesome if anyone could help.</p>