Saltar al contenido
View in the app

A better way to browse. Learn more.

Ayuda Excel

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

DEPURAR CÓDIGO DE FORMATO CONDICIONAL

publicado

Hola a todxs,

 

Simplemente os quería consultar una cosilla, ¿existe la posibilidad de depurar el siguiente código aun más?

(He utilizado la grabadora de macros, y casi siempre suele ser bastante enreversada en ese sentido. Por eso lo pregunto...)

 

... 
With Range(Cells(5, 20), Cells(5, 20).End(xlDown))
    .FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=0"
    .FormatConditions(Range(Cells(5, 20), Cells(5, 20).End(xlDown)).FormatConditions.Count).SetFirstPriority
        With .FormatConditions(1).Font
        ' Fuente de las celdas:
            .Bold = True
            .Color = -16776961
        End With
    .FormatConditions(1).StopIfTrue = False

    .FormatConditions.Add Type:=xlCellValue, Operator:=xlEqual, Formula1:="=1"
    .FormatConditions(Range(Cells(5, 20), Cells(5, 20).End(xlDown)).FormatConditions.Count).SetFirstPriority
        With .FormatConditions(1).Font
        ' Fuente de las celdas:
            .Bold = True
            .Color = -11489280
        End With
    .FormatConditions(1).StopIfTrue = False
End With
...

Gracias de antemano por vuestro tiempo.

Featured Replies

publicado

¡Hola, @paikerr!

Yo lo haría así:

1. Definiría un procedimiento base para los formatos condicionales:

Sub FormCond(rango As Range, formula$, kolor&)
    Dim FC As FormatCondition
    Set FC = rango.FormatConditions.Add(xlCellValue, xlEqual, formula)
    With FC
        With .Font
            .Bold = True: .Color = kolor
        End With
        .StopIfTrue = False
        .SetFirstPriority
    End With
End Sub

2. Desde mi procedimiento principal, llamaría este procedimiento base para ejecutar el Formato Condicional cada que lo necesite:

Sub Procedimiento()
    ' otro código ...

    FormCond Range(Cells(5, 20), Cells(5, 20).End(xlDown)), "=0", -16776961
    FormCond Range(Cells(5, 20), Cells(5, 20).End(xlDown)), "=1", -11489280

    ' otro código ...
End Sub

¡Bendiciones!

publicado
  • Autor

Gracias @johnmpl.

Copio tu código, aplico las pruebas necesarias y te digo algo (por si tuviera cualquier error).

  • Silvia bloqueó este tema

Archivado

Este tema está ahora archivado y está cerrado a más respuestas.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.