Skip to main content

Conas gach sraitheanna ina bhfuil téacs sonrach a scriosadh i gcolún i mbileoga Google?

Ag ceapadh, tá raon sonraí agat i mbileog google, anois, ba mhaith leat na sraitheanna a scriosadh bunaithe ar luachanna cille i gcolún. Mar shampla, ba mhaith liom gach sraith ina bhfuil an téacs “Complete” i gColum C. a scriosadh. Labhróidh mé faoin alt seo faoi conas é a réiteach i mbileoga Google.

Scrios gach sraitheanna ina bhfuil téacs sonrach laistigh de cholún le cód scripte


Scrios gach sraitheanna ina bhfuil téacs sonrach laistigh de cholún le cód scripte

Chun na sraitheanna uile a chuimsíonn an téacs sonrach i gcolún a bhaint, is féidir leis an gcód scripte seo a leanas fabhar a thabhairt duit, déan é seo le do thoil:

1. Cliceáil uirlisí > Eagarthóir scripte, féach ar an scáileán:

scrios sraitheanna ina bhfuil 1

2. I bhfuinneog an chóid oscailte nua, cóipeáil agus greamaigh an cód seo a leanas isteach i bhfuinneog an chóid bháin, féach an scáileán:

function deleteRows() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var s = ss.getSheetByName('delete containing');
  var r = s.getRange('C:C');
  var v = r.getValues();
  for(var i=v.length-1;i>=0;i--)
    if(v[0,i]=='Complete')
      s.deleteRow(i+1);
};

scrios sraitheanna ina bhfuil 2

nótaí: Sa chód thuas, “scriosadh ina bhfuil"Is é ainm na bileoige ina bhfuil na sonraí a theastaíonn uait a scriosadh,"C: C."Is é an colún le téacs sonrach ba mhaith leat a scriosadh as,"Comhlánaigh"Is é an téacs sonrach ar mhaith leat sraitheanna a scriosadh bunaithe air, athraigh iad de réir do riachtanas.

3. Ansin sábháil an cód seo, agus ansin cliceáil Rith cnaipe i bhfuinneog an chóid chun an cód script seo a fhorghníomhú, féach an pictiúr:

scrios sraitheanna ina bhfuil 3

4. Scriosadh na sraitheanna uile ina bhfuil an téacs sonrach “Comhlánaigh” ag an am céanna, féach an scáileán:

scrios sraitheanna ina bhfuil 4


Scrios gach sraith ina bhfuil téacs sonrach i mbileog oibre Excel:

Más mian leat na sraitheanna go léir a bhfuil luach sonrach iontu i gcolún a bhaint, beidh an Kutools le haghaidh Excel's Roghnaigh Cealla Sonracha is féidir le gné cabhrú leat gach sraitheanna a oireann do na critéir a roghnú, agus ansin ní gá duit ach na sraitheanna a scriosadh ag an am céanna.

scrios sraitheanna ina bhfuil 5

Kutools le haghaidh Excel: le níos mó ná 300 breiseán áisiúil Excel, saor in aisce le triail gan aon teorannú i 30 lá. Íoslódáil agus triail saor in aisce Anois!

Uirlisí Táirgiúlachta Oifige is Fearr

🤖 Kutools AI Aide: anailís sonraí a réabhlóidiú bunaithe ar: Forghníomhú Chliste   |  Gin Cód  |  Cruthaigh Foirmlí Saincheaptha  |  Anailís a dhéanamh ar Sonraí agus Cairteacha a Ghin  |  Feidhmeanna Kutools a agairt...
Gnéithe Coitianta: Faigh, Aibhsigh nó Aithnigh Dúblaigh   |  Scrios Sraitheanna Bána   |  Comhcheangail Colúin nó Cealla gan Sonraí a Chailleadh   |   Babhta gan Foirmle ...
Cuardaigh Super: Ilchritéir VLookup    VLookup Illuachanna  |   VLookup Trasna Ilbhileoga   |   Amharc doiléir ....
Liosta anuas Casta: Go tapa Cruthaigh Liosta Anuas   |  Liosta anuas Cleithiúnach   |  Liosta Buail Isteach Ilroghnacha ....
Bainisteoir Colún: Cuir Líon Sonrach Colún leis  |  Colúin Bog  |  Scoránaigh Stádas Infheictheachta na gColún Ceilte  |  Déan comparáid idir Raonta & Colúin ...
Gnéithe Réadmhaoin: Fócas Eangaí   |  Amharc Dearaidh   |   Barra Mór na Foirmle    Leabhar Oibre & Bainisteoir Bileog   |  Leabharlann Acmhainní (Uaththéacs)   |  Piocálaí Dáta   |  Comhcheangail Bileoga Oibre   |  Criptigh/Díchriptigh Cealla    Seol Ríomhphost trí Liosta   |  Scagaire Super   |   Scagaire Speisialta (scagaire trom/iodálach/stailc tríd...) ...
Barr 15 Uirlisí12 Téacs uirlisí (Cuir Téacs, Bain Carachtair,...)   |   50 + Cairt cineálacha (Cairt Gantt,...)   |   40+ Praiticiúil Foirmlí (Ríomh aois bunaithe ar lá breithe,...)   |   19 Insertion uirlisí (Cuir isteach Cód QR, Ionsáigh Pictiúr ón gCosán,...)   |   12 Tiontú uirlisí (Uimhreacha le Focail, Comhshó Airgeadra,...)   |   7 Cumaisc & Scoilt uirlisí (Sraitheanna Comhcheangail Casta, Cealla Scoilt,...)   |   ... agus eile

Supercharge Do Scileanna Excel le Kutools le haghaidh Excel, agus Éifeachtúlacht Taithí Cosúil Ná Roimhe. Kutools le haghaidh Excel Tairiscintí Níos mó ná 300 Ardghnéithe chun Táirgiúlacht a Treisiú agus Sábháil Am.  Cliceáil anseo chun an ghné is mó a theastaíonn uait a fháil ...

Tuairisc


Tugann Tab Oifige comhéadan Tabbed chuig Office, agus Déan Do Obair i bhfad Níos Éasca

  • Cumasaigh eagarthóireacht agus léamh tabbed i Word, Excel, PowerPoint, Foilsitheoir, Rochtain, Visio agus Tionscadal.
  • Oscail agus cruthaigh cáipéisí iolracha i gcluaisíní nua den fhuinneog chéanna, seachas i bhfuinneoga nua.
  • Méadaíonn do tháirgiúlacht 50%, agus laghdaíonn sé na céadta cad a tharlaíonn nuair luch duit gach lá!
Comments (16)
Rated 5 out of 5 · 1 ratings
This comment was minimized by the moderator on the site
This formula work for all column A and check all cells that contain some text > 0 and delete only the rows that contain some text in cells > 0

function deleteRows() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName('Sheet_name_here);
var r = s.getRange('A:A');
var v = r.getValues();
for(var i=v.length-1;i>=0;i--)
if(v[0,i]>'0')
s.deleteRow(i+2);
};
Rated 5 out of 5
This comment was minimized by the moderator on the site
Bonjour, j'aime beaucoup ce script. Moi je cherche un script qui permet de supprimer automatiquement tous les éléments ou contenus d'une colonne après chaque 1 min. Pas supprimer la colonne, mais le contenu de la colonne. Pouvez vous m'aider ?
This comment was minimized by the moderator on the site
How can I make this more versatile?

LEt's say that I create a list of blacklisted words in Sheet1 and I want to delete all the rows in Sheet2 that contain that words in column A. I'm totally stuck on this on Google Sheets
This comment was minimized by the moderator on the site
Any luck with this??
This comment was minimized by the moderator on the site
I fixed this for myself using the following.
The reason it is not working is because the v returns an array with only one item [0]
I also used Javascript .includes() so that you can delete records that "Contain" that text.


function deleteRows() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName('default');
var r = s.getRange('A:A');
var v = r.getValues();
for(var i=v.length-1;i>=1;i--)
if(v[i][0].includes("appleid.com")) {
console.log('deleted row ' + v[i][0]);
s.deleteRow(i+1);
}
};
This comment was minimized by the moderator on the site
Thank you so much. Works great for me
This comment was minimized by the moderator on the site
Great job, working seamlessly.
This comment was minimized by the moderator on the site
Figured it out, but having trouble making it work for larger sheets since it's exceeding maximum runtime. Basically, the data that was being returned for 'v' was an 'object' type so you had to JSON.stringify() it first in order to detect values.
<div data-tag="code">function deleteRows() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName('REPLACE WITH NAME OF SHEET');
var r = s.getRange('C:C'); // Replace 'C:C' to be the column you want to replace like start:end
var v = r.getValues();
for(var i=v.length-1;i>=0;i--) {
if(JSON.stringify(v[i]).includes('REPLACE WITH THE CHAR YOU WANT TO REPLACE')) {
s.deleteRow(i+1);
}
}
};
This comment was minimized by the moderator on the site
Why use the comma operator in v[0,i] ?
This comment was minimized by the moderator on the site
This seems to work only if a cell contains only the text specified. I want to delete rows with cells that contain other text including the text specific. I have a bunch of email addresses and want to be rid of rows containing Gmail addresses, therefore I'm looking for cells containing 'gmail.com'.

No luck here.
This comment was minimized by the moderator on the site
Replace this line: if(v[0,i]=='Complete')
With this: if(v[0,i].indexOf('gmail') > -1)
This comment was minimized by the moderator on the site
Doesn't work for me, either.
This comment was minimized by the moderator on the site
I tried that. It's still not working.
This comment was minimized by the moderator on the site
Hello,
Can modify the below code to delete the coloured row instead of text


function deleteRows() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName('delete containing');
var r = s.getRange('C:C');
var v = r.getValues();
for(var i=v.length-1;i>=0;i--)
if(v[0,i]=='Complete')
s.deleteRow(i+1);
};
This comment was minimized by the moderator on the site
Hello,
Can I modify the below code to delete a coloured cell instead of specific text:


function deleteRows() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var s = ss.getSheetByName('delete containing');
var r = s.getRange('C:C');
var v = r.getValues();
for(var i=v.length-1;i>=0;i--)
if(v[0,i]=='Complete')
s.deleteRow(i+1);
};
This comment was minimized by the moderator on the site
Does nothing at all, not sure how to fix this.
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations