Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
Formato condicional si una celda coincide con una de una lista de una hoja diferente usando Apps Script

Tengo una lista cambiante de números en una pestaña a la que me gustaría aplicar formato condicional, si la celda está presente en otra lista de números, en una hoja diferente.

Ciudades Potenciales/Códigos Postales

Lista de códigos postales bloqueados

Me gustaría que los códigos postales en la hoja principal de "Ciudades potenciales" tengan formato cuando aparecen en la hoja "Códigos postales bloqueados".

El propósito es crear un cambio de formato que muestre claramente al usuario si un código postal que intenta ingresar está bloqueado (o en la lista). El formato condicional normal no funciona porque copiar/pegar sobrescribirá las reglas de CF. También necesito poder aplicar la solución a varias hojas diferentes, que están comparando sus celdas con la lista de celdas bloqueadas.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Puede crear un onEdit() para su hoja de cálculo de ciudades potenciales que verifica la hoja de cremalleras bloqueadas en busca de una coincidencia y aplica algún tipo de formato en consecuencia.

Por ejemplo:

 function checkForBlockedZips(e) { // do nothing if not column D if (e.range.getColumn() !== 4) return // get list of zips from blocked zips sheet const blockedZipsSsId = "your-spreadsheet-id" const blockedZipsSs = SpreadsheetApp.openById(blockedZipsSsId) const blockedZipsSheet = blockedZipsSs.getSheetByName("Sheet1") const zipCodes = blockedZipsSheet.getRange("A2:A").getValues() .flat(2) .filter(x => x) // check if the entered value is in the list of blocked zips if (~zipCodes.indexOf(e.range.getValue())) { // create cell style const strikethrough = SpreadsheetApp.newTextStyle() .setStrikethrough(true) .build() const richText = SpreadsheetApp.newRichTextValue() .setText(e.range.getValue()) .setTextStyle(strikethrough) .build() // set the cell to have the desired rich text style e.range.setRichTextValue(richText).setBackground("yellow") } else { // if the value is not a blocked zip then reset the cell style const nostrikethrough = SpreadsheetApp.newTextStyle() .setStrikethrough(false) .build() const richText = SpreadsheetApp.newRichTextValue() .setText(e.range.getValue()) .setTextStyle(nostrikethrough) .build() e.range.setRichTextValue(richText).setBackground("white") } }

Cosas a tener en cuenta:

  • Debe usar e.range.getValue() en lugar de e.value para que se puedan leer los valores copiados/pegados
  • Debe agregar este script a la hoja de Ciudades potenciales y autorizarlo como activador instalable
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!