Enter the same value in every cell of a Range in Google Sheets using Apps Script

Last updated: February 09, 2025

I recently found out that there is a very easy way to enter the same value in every cell of a Range in Google Sheets using Apps Script.

All you have to do is select the range and then use the setValue() method of the Range object.

function setValueToEveryCellInRange() {
   var range = SpreadsheetApp.getActiveSheet().getRange(1,1,5,5);
   range.setValue("Hello");
}

The above code selects the range A1:E5 of the sheet that is active (i.e., the selected sheet in your spreadsheet) and enters the text "Hello" in every cell.

Screenshot of a Google Sheets spreadsheet.

Thanks for reading!

DISCLAIMER: This content is provided for educational purposes only. All code, templates, and information should be thoroughly reviewed and tested before use. Use at your own risk. Full Terms of Service apply.

Small Scripts, Big Impact

Join 1,500+ professionals who are supercharging their productivity with Google Sheets automation

Exclusive Google Sheets automation tutorials and hands-on exercises
Ready-to-use scripts and templates that transform hours of manual work into seconds
Email updates with new automation tips and time-saving workflows

By subscribing, you agree to our Privacy Policy and Terms of Service