Nuno
Nuno

Reputation: 1

I want to delete all rows in a spreadsheet that do not have any value in the cells in Column A

I want to delete all rows in a spreadsheet that do not have any value in the cells in Column A. What is the script/formula for this function? Thanks

Upvotes: 0

Views: 44

Answers (1)

Yuri Khristich
Yuri Khristich

Reputation: 14502

If you don't need to preserve colors, fonts, etc, here is a simple solution:

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getDataRange();
var data  = range.getValues().filter(row => (row[0]));
range.clear().offset(0,0,data.length).setValues(data);

Upvotes: 1

Related Questions