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.

Macro no ejecuta un IF

publicado

Hola, repasando las macros de mi libro me he dado cuenta de que tengo un IF compuesto que no lo ejecuta y no le veo la razón. ¿Podéis iluminarme? Gracias.

If CeldaActual.Value >= 11 And CeldaActual.Value <= 13 Then
        
            CeldaActual.Interior.ColorIndex = None
            CeldaActual.Font.ColorIndex = 3  'Rojo
            CeldaActual.Font.Bold = True

 

Tensión_macros_1bis.xlsm

Featured Replies

publicado

El problema no lo tienes en ese If, lo tienes en el siguiente que entra en conflicto al cumplirse la condición de <=5.

Debes asegurarte que las condiciones solo se evalúan en las celdas adecuadas.

Prueba esta macro:

Sub Formato_Condicional()
Application.ScreenUpdating = False
For Each CeldaActual In Range("B2:H" & Cells(Rows.Count, "A").End(xlUp).Row)
   '--
   CeldaActual.HorizontalAlignment = xlCenter
   CeldaActual.Interior.ColorIndex = xlNone
   CeldaActual.Font.Color = vbBlack
   CeldaActual.Font.Bold = False
   '--
   If Range("A" & CeldaActual.Row) Like "SISTÓLICA*" Then
      If CeldaActual.Value >= 11 And CeldaActual.Value <= 13 Then
         CeldaActual.Font.Color = vbRed
         CeldaActual.Font.Bold = True
       End If
   End If
   '--
   If Range("A" & CeldaActual.Row) Like "DIASTÓLICA*" Then
      If CeldaActual.Value <= 5 Then
         CeldaActual.Font.Color = vbRed
         CeldaActual.Font.Bold = True
       End If
   End If
   '--
   If Range("A" & CeldaActual.Row) Like "PULSACIONES*" Then
      If CeldaActual.Value >= 65 And CeldaActual.Value <= 80 Then
         CeldaActual.Font.Color = vbRed
         CeldaActual.Font.Bold = True
       End If
   End If
   '--
   If Range("A" & CeldaActual.Row) Like "Semana*" Then
      CeldaActual.Interior.Color = vbYellow
   End If
   '--
   If Range("A" & CeldaActual.Row - 1) Like "Semana*" And _
      Range("A" & CeldaActual.Row) = "" Then
      CeldaActual.Interior.Pattern = xlGray25
   End If
   '--
   If Range("A" & CeldaActual.Row - 1) Like "PULSACIONES*" Then
      CeldaActual.Interior.Color = vbBlack
   End If
   '--
Next
End Sub

 

publicado
  • Autor

Gracias por tu tiempo y ayuda.?

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.