Reputation: 37
I am having a spreadsheet with thousands of rows and some entries have "#N/A" in the first column as a result of a lookup. I want those rows to be copied entirely on a new sheet.
Example:
ID | Other Data |
---|---|
#N/A | row1 |
123 | row2 |
#N/A | row3 |
#N/A | row4 |
#N/A | row5 |
456 | row6 |
The new sheet should contain the rows with "#N/A" in the ID field
ID | Other Data |
---|---|
#N/A | row1 |
#N/A | row3 |
#N/A | row4 |
#N/A | row5 |
Upvotes: 1
Views: 1398
Reputation: 5953
You can refer to this sample code on how to filter data from sheet and write the to a new sheet using apps script
function onOpen() {
var ui = SpreadsheetApp.getUi();
// Or DocumentApp or FormApp.
ui.createMenu('Custom Menu')
.addItem('Filter N/A', 'FilterNA')
.addToUi();
}
function FilterNA(){
var sheet = SpreadsheetApp.getActiveSheet();
var newSheet = SpreadsheetApp.getActiveSpreadsheet().insertSheet();
var data = sheet.getDataRange().getDisplayValues();
var newData = data.filter(row => ["ID","#N/A"].includes(row[0]));
newSheet.getRange(1,1,newData.length,newData[0].length).setValues(newData);
}
Upvotes: 0
Reputation: 1832
connect the sheets with a query, is how I would do it:
=query(importrange("https://docs.google.com/spreadsheets/d/ID",
"'SHEET 1'!A2:Z"),
"select * where Col1 = '#N/A'")
You'll have to ok the connection between the sheets.
Upvotes: 1
Reputation: 351
Just use the FILTER formula: =FILTER(A2:B100, A2:A100="#N/A")
Upvotes: 1