[GAS Beginner Series #10] Make Google Sheets Text Bold Automatically: How to Use Range.setFontWeight()

“I created a table in Google Sheets, but the headers and data look the same and it’s hard to read at a glance…” “I want to automatically make important numbers or recommended spots bold to make them stand out!”

Selecting cells manually and clicking the bold button (or pressing Ctrl + B / Cmd + B) is easy enough once or twice. But formatting headers for dozens of daily reports or automatically updated lists by hand every time can be a real hassle, right?

That’s where Google Apps Script (GAS) and Range.setFontWeight() come to the rescue!

Once you learn this method, you can instantly turn text in targeted cells or ranges bold using code.

In this 10th lesson, I’ll explain how to use Range.setFontWeight() to control font weight effortlessly—making it so clear and beginner-friendly that you’ll never feel lost!

To wrap up our milestone “Phase 1: GAS Basics and Single Cell Operations (Lessons 1–10)”, we’ll format a fun “Sapporo Soup Curry Tour List” spreadsheet while mastering everything from fundamentals to practical work techniques and common beginner traps!

1. Quick Review with the House, Room, Furniture Analogy: Where setFontWeight() Fits In

Before we start writing code, let’s review where this method fits within the spreadsheet hierarchy using our familiar “House, Room, Furniture” analogy.

When working with spreadsheets in GAS, you always navigate through the following hierarchy:

[House] Entire Spreadsheet File (Spreadsheet)
  └── [Room] Individual Sheet Tab (Sheet)
        └── [Furniture] Cell or Range (Range) ★ Apply styling (bold) here!
  • [House] = Entire Spreadsheet File
    • Retrieved using SpreadsheetApp.getActiveSpreadsheet() learned in Lesson 2.
  • [Room] = Individual Sheet Tab
    • A specific tab like “Chuo Ward Area” retrieved using ss.getActiveSheet() learned in Lesson 3.
  • [Furniture] = Cell or Cell Range (Range)
    • The specific grid cells targeted using sheet.getRange("A1:C1") learned in Lesson 4.

The method we’re learning today, setFontWeight(), is an instruction (method) for that targeted “furniture” (cell): “Repaint this furniture to make the text bold and stand out!”

2. What Is Range.setFontWeight()?

Range.setFontWeight() is a method that sets the font weight (text thickness) of specified cells (Range object).

Basic Syntax

// Get a cell (or cell range) and call setFontWeight
range.setFontWeight("desired_weight");

In actual practice, you chain the methods together using dots (.) like this:

var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var range = sheet.getRange("A1:C1");

// Make the text in range A1:C1 bold
range.setFontWeight("bold");

Only Two Argument Values You Need to Know!

The values (arguments) you pass inside the parentheses () of setFontWeight() are basically limited to these two options:

Setting Value (String)PronunciationEffectCommon Use Cases
"bold"BoldMakes text boldTable headers, total rows, emphasizing key data
"normal"NormalResets text to normal weightClearing formatting, standard text

*It’s super simple—you just pass "bold" or "normal" wrapped in double quotes "" as the argument.

3. STEP 1: Preparation! Create the “Sapporo Soup Curry Tour List”

Let’s learn by doing! Today, we’ll create a practice spreadsheet listing popular soup curry restaurants in Sapporo.

Setup Steps

  1. Open Google Sheets in your browser and create a new spreadsheet.
  2. Change the file title (top left) to “Sapporo Soup Curry Tour List”.
  3. Rename the sheet tab at the bottom to “Chuo Ward Area”.
  4. Enter the following data into the cells (no need to change fonts or set bold manually—just plain text is fine).
ABC
1Shop NameAreaRating
2Magic SpiceHongo-dori (Nango 7-chome)★★★★★
3GarakuSusukino / Odori★★★★☆
4Okushiba ShotenSapporo Station Chikaho★★★★★
5PicanteSapporo Station North Exit★★★★☆
  1. Once entered, keep the “Chuo Ward Area” sheet open (active).

4. STEP 2: Just a Few Lines! Automatically Format Row 1 Headers as Bold

Now that our spreadsheet is ready, let’s open the GAS Apps Script editor and write a script to automatically make the row 1 header (A1:C1) bold!

1. Open the Script Editor

From the top menu of Google Sheets, click Extensions > Apps Script.

2. Enter the Code

Clear out the default function myFunction() { ... } code completely, then copy and paste the following code into the editor:

function formatCurryListHeader() {
  // ① Get the "House" (Spreadsheet file) and "Room" (currently active sheet)
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getActiveSheet();
  
  // ② Get the header range in row 1 (A1 to C1)
  var headerRange = sheet.getRange("A1:C1");
  
  // ③ Format text in the retrieved range as "bold"
  headerRange.setFontWeight("bold");
  
  // ④ Output confirmation log that the process completed
  Logger.log("Header (A1:C1) bold formatting completed successfully!");
}

3. Detailed Breakdown of the Code

Let’s break down how this code works line by line:

  • var ss = SpreadsheetApp.getActiveSpreadsheet();
    • This is the method we learned in Lesson 2. It gets the entire active “Sapporo Soup Curry Tour List” spreadsheet file.
  • var sheet = ss.getActiveSheet();
    • Learned in Lesson 3. It retrieves the active sheet tab (“Chuo Ward Area”).
  • var headerRange = sheet.getRange("A1:C1");
    • Learned in Lesson 4. It selects the rectangular area from cell A1 to C1 and assigns it to the variable headerRange.
  • headerRange.setFontWeight("bold");
    • The star of today’s lesson! Running .setFontWeight("bold") on the targeted range instantly converts all text in A1, B1, and C1 into bold font.

4. Save and Run

  1. Click the floppy disk icon (Save) at the top of the script editor.
  2. Ensure the function dropdown is set to formatCurryListHeader, then click Run.
  3. If this is your first time running a script, Google may show a authorization screen. Follow the steps introduced in Lesson 2 to grant permission.

5. Check the Results

Switch back to your Google Sheets tab!

If the header text in row 1 (“Shop Name”, “Area”, “Rating”) has turned into clear, crisp bold text in an instant, you’ve succeeded!

5. STEP 3: Ready for Work! 4 Practical Techniques using setFontWeight()

Beyond simply bolding headers, here are 4 practical techniques that come in handy for daily work and tool development.

Technique 1: Automatically Bold Data That Meets Specific Conditions (Conditional Bolding)

In real-world tasks, you often want to highlight specific data—like rows where sales exceeded targets or items low on stock.

Here, let’s combine getValue() (data reading) from Lesson 5 with an if statement (conditional logic) to automatically bold only the shops with a 5-star rating (“★★★★★”)!

function highlightTopRankedStores() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  
  // Check row by row from row 2 to row 5
  for (var row = 2; row <= 5; row++) {
    
    // Get the value in column C (Rating) (using getValue from Lesson 5!)
    var rating = sheet.getRange(row, 3).getValue();
    
    // If the rating is "★★★★★"...
    if (rating === "★★★★★") {
      // Make column A (Shop Name) for that row bold!
      sheet.getRange(row, 1).setFontWeight("bold");
    }
  }
  
  Logger.log("Bold highlighting for 5-star shops completed!");
}

[Result]

Only the shop names “Magic Spice” and “Okushiba Shoten” match the condition and are automatically formatted in bold!

By letting code evaluate conditions for you, you can instantly highlight key data even across large spreadsheets with thousands of rows.

Technique 2: Combine with setBackground() to Create Professional Headers

Combining this with setBackground() (changing background color) from Lesson 9 dramatically boosts visual design, giving you clean, professional tables anyone can read at a glance!

function styleProfessionalHeader() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var headerRange = sheet.getRange("A1:C1");
  
  // 1. Set background color to a chic dark gray (#434343)
  headerRange.setBackground("#434343");
  
  // 2. Set font color to white (#ffffff) for readability
  headerRange.setFontColor("#ffffff");
  
  // 3. Make text bold for emphasis
  headerRange.setFontWeight("bold");
}

*setFontColor() is the method to change font color. Combining background color, text color, and bold styling is a classic design pattern frequently used in automated reporting.

Technique 3: Remove Bold (Reset) Back to Standard Text

When building automation tools, you often want to reset all formatting at the start of a process.

To restore bold text back to standard weight, simply pass "normal" as the argument.

function resetAllFontWeight() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  
  // Reset bold formatting across the entire table (A1:C5) back to normal weight
  sheet.getRange("A1:C5").setFontWeight("normal");
  
  Logger.log("Bold formatting has been reset.");
}

Technique 4: Bold Multiple Disjointed Ranges (Headers and Total Rows)

If you want to bold separate areas—such as a header row at the top and a total row at the bottom—you can use getRangeList() or run setFontWeight("bold") sequentially on each range.

function highlightHeaderAndTotal() {
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  
  // Make row 1 (header) and row 5 (bottom row) bold respectively
  sheet.getRange("A1:C1").setFontWeight("bold");
  sheet.getRange("A5:C5").setFontWeight("bold");
}

6. The 5 Common Traps Beginners Fall Into (And How to Fix Them)

If your code isn’t working or throws an error, don’t panic! Check these 5 common pitfalls—almost 100% of beginner issues stem from one of these!

Trap 1: String Argument Errors (Capitalization, Typos, Extra Spaces)

The most frequent issue is mistyping "bold" or "normal".

// ✕ Incorrect examples that cause errors or fail to take effect
range.setFontWeight("BOLD");   // Uppercase used (must be lowercase)
range.setFontWeight("Bold");   // Capitalized first letter
range.setFontWeight("bold ");  // Contains an unwanted trailing space
range.setFontWeight("太字");   // Passing non-English text
range.setFontWeight(true);     // Passing a boolean instead of a string

// ◯ Correct examples
range.setFontWeight("bold");
range.setFontWeight("normal");

[Fix]

Always stick to the rule: argument strings passed to setFontWeight() must be all-lowercase English text: "bold" or "normal"!

Trap 2: Lowercase ‘w’ in setFontweight() (The CamelCase Trap)

JavaScript/GAS uses a naming convention called CamelCase, where subsequent words are capitalized.

  • ✕ setFontweight("bold") (the ‘w’ is lowercase)
  • ✕ SetFontWeight("bold") (the leading ‘S’ is capitalized)
  • ◯ setFontWeight("bold") (only the W in Weight is capitalized!)

[Error Message You’ll See]

TypeError: range.setFontweight is not a function

(Translation: The method setFontweight was not found. Check your capitalization.)

[Fix] Type setFont... and select the method from the autocomplete suggestions using Tab or Enter to prevent typos completely!

Trap 3: Writing sheet.setFontWeight() Without Calling getRange() First

This is another super common mistake among beginners.

// ✕ Incorrect: Trying to call setFontWeight directly on the sheet ("Room")
sheet.setFontWeight("bold"); 

// ◯ Correct: Get the cells ("Furniture") from the sheet first, then call setFontWeight
sheet.getRange("A1:C1").setFontWeight("bold");

setFontWeight() is a method belonging to Range (cells), not Sheet (the tab). Always chain them in the order: Sheet ➡ Range (getRange) ➡ Bold (setFontWeight).

Trap 4: Bold Formatting Remains After Running clearContent()

clearContent() from Lesson 8 clears only the text and values inside the cells.

Because of this, if you type new text after clearing contents, the previously applied bold styling will linger and format your new text in bold automatically.

[Fix] To wipe away styling like bold weights and background colors alongside text, use Range.clearFormat() (clears formatting only) or Range.clear() (clears everything) which we’ll cover in future lessons!

Trap 5: Running the Script Without Saving Changes First

If you edit your code and click “Run” without pressing the floppy disk icon (Save) first, the script editor will execute the old, unsaved version of your code.

If you feel like “the code is correct, but nothing changes,” check whether the orange dot (unsaved indicator) appears next to your file name, and make sure to save before running!

7. Summary & Phase 1 (Lessons 1–10) Completion! Next Lesson Preview

In this lesson, we took a deep dive into Range.setFontWeight() for making text bold in specified cells or ranges.

Key Takeaways

  1. Instantly make text bold using range.setFontWeight("bold")
  2. Reset text back to normal weight using range.setFontWeight("normal")
  3. Only two lowercase string arguments are used: "bold" and "normal"
  4. Combine with getValue() (reading data) or setBackground() (background color) to build powerful automated formatting tools for work

🎉 Congratulations on Completing Phase 1!!

Great job reaching the end of Lessons 1 through 10! Let’s take a quick look back at all the GAS skills you’ve mastered so far:

  • Lesson 1: Output logs to the script editor using Logger.log()
  • Lesson 2: Access the spreadsheet file using SpreadsheetApp.getActiveSpreadsheet()
  • Lesson 3: Access active sheets using Spreadsheet.getActiveSheet()
  • Lesson 4: Target specific cells and ranges using Sheet.getRange()
  • Lesson 5: Read cell values using Range.getValue()
  • Lesson 6: Write data to cells using Range.setValue()
  • Lesson 7: Append new rows of data using Sheet.appendRow()
  • Lesson 8: Clear cell data using Range.clearContent()
  • Lesson 9: Change cell background colors using Range.setBackground()
  • Lesson 10: Format text as bold using Range.setFontWeight()

In just 10 lessons, you’ve mastered the complete fundamental cycle of spreadsheet automation: reading data, calculating, writing values, and formatting cleanly! This is a huge milestone in your journey as a GAS developer.

Preview: What’s Coming in Phase 2!

Starting with our next lesson, we’re diving into [Phase 2: Multiple Cells, Arrays, and Table Operations (Lessons 11–20)]!

Up until now, we’ve worked with fixed locations like cell “A1” or range “A1:C1”. But in real-world workflows, you rarely know in advance how many rows of data you’ll have each day, and you’ll need to append actions dynamically to the very last row!

In Lesson 11, we’ll cover Sheet.getLastRow()—widely considered one of the most critical methods for practical data automation!

You’ll learn how GAS automatically detects the last row containing data. Once you master this, you can build production-ready automation systems that work seamlessly no matter how large your dataset grows!