Note: The other languages of the website are Google-translated. Back to English
Iniciar sesión  \/ 
x
or
x
Inscríbete  \/ 
x

or

¿Cómo aplicar degradado de color en varias celdas?

En Excel, podemos rellenar fácilmente el color de fondo en una celda o en varias celdas, pero, a veces, necesitamos que el color se llene con un degradado como se muestra en la siguiente captura de pantalla, ¿cómo podría obtener el degradado de color en una celda o en varias celdas en Excel?

Degradado de color a una celda Gradiente de color en varias celdas
gradiente de color doc 1 gradiente de color doc 2

Aplicar color degradado a una celda con la función Formato de celdas

Aplicar color degradado en varias celdas con código VBA


flecha azul burbuja derecha Aplicar color degradado a una celda con la función Formato de celdas

En Excel, la función Formato de celdas puede ayudarlo a completar el degradado de color en una celda, haga lo siguiente:

1. Seleccione una celda o varias celdas que desee que se llenen con un degradado de color en cada celda, y luego haga clic derecho para elegir Formato de celdas desde el menú contextual, en el Formato de celdas cuadro de diálogo, debajo del Llene pestaña, haga clic en Efectos de relleno botón, ver captura de pantalla:

gradiente de color doc 3

2. En la Efectos de relleno cuadro de diálogo, seleccione dos colores que desee utilizar de las dos listas desplegables de Colores sección y, a continuación, seleccione uno de los estilos de sombreado que desee, como horizontal, vertical, etc. Ver captura de pantalla:

gradiente de color doc 4

3. Luego haga clic OK > OK para cerrar los cuadros de diálogo, y el color del degradado se rellena para cada celda como se muestra en la siguiente captura de pantalla:

gradiente de color doc 5


flecha azul burbuja derecha Aplicar color degradado en varias celdas con código VBA

El método anterior puede ayudarnos a colorear el degradado dentro de una celda individual, si necesita sombrear el degradado de color en varias celdas, debe aplicar un código VBA para resolverlo.

1. Primero, complete un color de fondo específico en un rango de celdas.

2. Mantenga pulsado el ALT + F11 teclas para abrir el Microsoft Visual Basic para aplicaciones ventana.

3. Hacer clic recuadro > Móduloy pegue el siguiente código en el Módulo Ventana.

Código de VBA: aplique color degradado en varias celdas:

Sub colorgradientmultiplecells()
'Updateby Extendoffcie 
    Dim xRg As Range
    Dim xTxt As String
    Dim xCell As Range
    Dim xColor As Long
    Dim I As Long
    Dim K As Long
    Dim xCount As Long
    On Error Resume Next
    If ActiveWindow.RangeSelection.Count > 1 Then
      xTxt = ActiveWindow.RangeSelection.AddressLocal
    Else
      xTxt = ActiveSheet.UsedRange.AddressLocal
    End If
LInput:
    Set xRg = Application.InputBox("please select the cells range:", "Kutools for Excel", xTxt, , , , , 8)
    If xRg Is Nothing Then Exit Sub
    If xRg.Areas.Count > 1 Then
        MsgBox "does not support multiple selections", vbInformation, "Kutools for Excel"
        GoTo LInput
    End If
    On Error Resume Next
    Application.ScreenUpdating = False
    xCount = xRg.Rows.Count
    For K = 1 To xRg.Columns.Count
        xColor = xRg.Cells(1, K).Interior.Color
        For I = xCount To 1 Step -1
            xRg.Cells(I, K).Interior.Color = xColor
            xRg.Cells(I, K).Interior.TintAndShade = (xCount - (I - 1)) / xCount
        Next
    Next
End Sub

4. Entonces presione F5 para ejecutar este código, y aparece un cuadro de aviso para recordarle que seleccione las celdas de color que desea rellenar con color degradado, vea la captura de pantalla:

 

gradiente de color doc 6

5. Y luego haz clic OK botón, el color dentro de varias celdas se ha mostrado como color degradado, vea la captura de pantalla:

 

gradiente de color doc 7


Las mejores herramientas de productividad de oficina

Kutools para Excel resuelve la mayoría de sus problemas y aumenta su productividad en un 80%

  • Reutilizar: Inserte rápidamente fórmulas complejas, gráficos y cualquier cosa que hayas usado antes; Cifrar celdas con contraseña; Crear lista de distribución y enviar correos electrónicos ...
  • Barra de súper fórmula (edite fácilmente varias líneas de texto y fórmulas); Diseño de lectura (leer y editar fácilmente un gran número de celdas); Pegar en rango filtrado...
  • Combinar celdas / filas / columnas sin perder datos; Contenido de celdas divididas; Combinar filas / columnas duplicadas... Prevenir celdas duplicadas; Comparar rangos...
  • Seleccione Duplicado o Único Filas; Seleccionar filas en blanco (todas las celdas están vacías); Super Find y Fuzzy Find en muchos libros de trabajo; Selección aleatoria ...
  • Copia exacta Varias celdas sin cambiar la referencia de la fórmula; Crear referencias automáticamente a varias hojas; Insertar viñetas, Casillas de verificación y más ...
  • Extraer texto, Agregar texto, Eliminar por posición, Quitar espacio; Crear e imprimir subtotales de paginación; Convertir entre contenido de celdas y comentarios...
  • Súper filtro (guardar y aplicar esquemas de filtros a otras hojas); Orden avanzado por mes / semana / día, frecuencia y más; Filtro especial en negrita, cursiva ...
  • Combinar libros y hojas de trabajo; Combinar tablas basadas en columnas clave; Dividir datos en varias hojas; Conversión por lotes de xls, xlsx y PDF...
  • Más de 300 potentes funciones. Compatible con Office / Excel 2007-2019 y 365. Compatible con todos los idiomas. Fácil implementación en su empresa u organización. Características completas Prueba gratuita de 30 días. Garantía de devolución de dinero de 60 días.
pestaña kte 201905

Office Tab lleva la interfaz con pestañas a Office y hace que su trabajo sea mucho más fácil

  • Habilite la edición y lectura con pestañas en Word, Excel, PowerPoint, Publisher, Access, Visio y Project.
  • Abra y cree varios documentos en nuevas pestañas de la misma ventana, en lugar de en nuevas ventanas.
  • ¡Aumenta su productividad en un 50% y reduce cientos de clics del mouse todos los días!
officetab parte inferior
Say something here...
symbols left.
You are guest
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    MArcela CAmargo · 7 months ago
    Hello, How can I aply this formula for two colors, above I can't watch de solution. Please

  • To post as a guest, your comment is unpublished.
    Gordon · 10 months ago
    Hello, Can you apply this to a range like 1 to 5 , cells having a number in them, having the 5 as the darkest ?

    Would Kutools be able to do a little similar to above , but then arrange a row of numbers into a scale - not good at explaining. Say a survey answering on a scale of 1 to 5 , then graphical show one bar per question showing percent of answers in 1, 2 ,3 ,4 ,5 ; 5% 1's, 10% 2's 15% 3's and 50% 4's , 20% 5's but showing a gradient of colours in a horizontal bar (better if 2 colours).

    Thanks , Gord
  • To post as a guest, your comment is unpublished.
    Alan · 1 years ago
    Hi, I've tried copying the VBA code but when I try to run it I keep getting a message that says 'Compile Error: Invalid Outside Procedure'....


    How do I fix this??


    Thanks!
  • To post as a guest, your comment is unpublished.
    Jasmin · 2 years ago
    Hello, how can I go from yellow to red (for example)? It works only from White to an other color. I work with the code from left to right.
    • To post as a guest, your comment is unpublished.
      skyyang · 2 years ago
      Hello, Jasmin,
      Sorry for that, this code only applied to one color, and if you want to fill gradient from left to tight, the below comment has the solution, please check it.
      Thank you!
      • To post as a guest, your comment is unpublished.
        Gord Thompson · 9 months ago
        Hello, Can you apply this to a range like 1 to 5 , cells having a number in them, having the 5 as the darkest ?

        Would Kutools be able to do a little similar to above , but then arrange a row of numbers into a scale - not good at explaining. Say a survey answering on a scale of 1 to 5 , then graphical show one bar per question showing percent of answers in 1, 2 ,3 ,4 ,5 ; 5% 1's, 10% 2's 15% 3's and 50% 4's , 20% 5's but showing a gradient of colours in a horizontal bar (better if 2 colours).

        Thanks , Gord
  • To post as a guest, your comment is unpublished.
    Piyaphan · 2 years ago
    Why I got Black-White color replace my gradient
    • To post as a guest, your comment is unpublished.
      Nicolas · 8 months ago
      Hello! I have the same problem, i choose the colors for my gradient but when applying the code it turns into black to white gradient. Anyy help?? thanks!
    • To post as a guest, your comment is unpublished.
      skyyang · 2 years ago
      Hello, Piyaphan,
      The above code works well in my worksheet, which Excel version do you use?
      Or you can give your problem more detailed.
      Thank you!
  • To post as a guest, your comment is unpublished.
    paul · 3 years ago
    hey, I'm not that used to VBA codes. How do I set another color in the code?
    • To post as a guest, your comment is unpublished.
      skyyang · 3 years ago
      Hello, paul,
      If you want to set another color, you just need to fill your desired color to the cells, and then apply the above code in this article.
      Please try it.
      • To post as a guest, your comment is unpublished.
        paul · 3 years ago
        thanks! it works :)
  • To post as a guest, your comment is unpublished.
    Sean · 3 years ago
    How do I get this to have the gradient go left to right?
    • To post as a guest, your comment is unpublished.
      skyyang · 3 years ago
      Hello, Sean,
      To apply the color gradient from left to right, please use the following VBA code:

      Sub colorgradientmultiplecells()
      Dim xRg As Range
      Dim xTxt As String
      Dim xCell As Range
      Dim xColor As Long
      Dim I As Long
      Dim K As Long
      Dim xCount As Long
      On Error Resume Next
      If ActiveWindow.RangeSelection.Count > 1 Then
      xTxt = ActiveWindow.RangeSelection.AddressLocal
      Else
      xTxt = ActiveSheet.UsedRange.AddressLocal
      End If
      LInput:
      Set xRg = Application.InputBox("please select the cells range:", "Kutools for Excel", xTxt, , , , , 8)
      If xRg Is Nothing Then Exit Sub
      If xRg.Areas.Count > 1 Then
      MsgBox "does not support multiple selections", vbInformation, "Kutools for Excel"
      GoTo LInput
      End If
      On Error Resume Next
      Application.ScreenUpdating = False
      xCount = xRg.Columns.Count
      For K = 1 To xRg.Rows.Count
      xColor = xRg.Cells(K, 1).Interior.Color
      For I = xCount To 1 Step -1
      xRg.Cells(K, I).Interior.Color = xColor
      xRg.Cells(K, I).Interior.TintAndShade = (xCount - (I - 1)) / xCount
      Next
      Next
      End Sub

      Hope it can help you, thank you!
      • To post as a guest, your comment is unpublished.
        Ashley · 3 years ago
        How can I make the code to go it from right to left, Thanks in advance
        • To post as a guest, your comment is unpublished.
          skyyang · 2 years ago
          Hello, Ashley,
          To make the color gradient from right to left, the following vba code can help you, please try it.

          Sub colorgradientmultiplecells()
          Dim xRg As Range
          Dim xTxt As String
          Dim xCell As Range
          Dim xColor As Long
          Dim I As Long
          Dim K As Long
          Dim xCount As Long
          On Error Resume Next
          If ActiveWindow.RangeSelection.Count > 1 Then
          xTxt = ActiveWindow.RangeSelection.AddressLocal
          Else
          xTxt = ActiveSheet.UsedRange.AddressLocal
          End If
          LInput:
          Set xRg = Application.InputBox("please select the cells range:", "Kutools for Excel", xTxt, , , , , 8)
          If xRg Is Nothing Then Exit Sub
          If xRg.Areas.Count > 1 Then
          MsgBox "does not support multiple selections", vbInformation, "Kutools for Excel"
          GoTo LInput
          End If
          On Error Resume Next
          Application.ScreenUpdating = False
          xCount = xRg.Columns.Count
          For K = 1 To xRg.Rows.Count
          xColor = xRg.Cells(K, 1).Interior.Color
          For I = xCount To 1 Step -1
          xRg.Cells(K, I).Interior.Color = xColor
          xRg.Cells(K, I).Interior.TintAndShade = I / xCount
          Next
          Next
          End Sub
          • To post as a guest, your comment is unpublished.
            Kristina · 1 years ago
            Is it possible to perform this gradient but from bottom left to top right?
      • To post as a guest, your comment is unpublished.
        Sean · 3 years ago
        Is it possible to post a code that does gradient from top to bottom? I would really appreciate it.
        • To post as a guest, your comment is unpublished.
          Laura · 1 years ago
          I would need the code from the darkest shade at the top to the lighter shade at the bottom as well.. :(
          • To post as a guest, your comment is unpublished.
            skyyang · 1 years ago
            Hi, Laura,
            To sove your task, please apply the folloiwng code:

            Sub colorgradientmultiplecells()
            'Updateby Extendoffcie
            Dim xRg As Range
            Dim xTxt As String
            Dim xCell As Range
            Dim xColor As Long
            Dim I As Long
            Dim K As Long
            Dim xCount As Long
            On Error Resume Next
            If ActiveWindow.RangeSelection.Count > 1 Then
            xTxt = ActiveWindow.RangeSelection.AddressLocal
            Else
            xTxt = ActiveSheet.UsedRange.AddressLocal
            End If
            LInput:
            Set xRg = Application.InputBox("please select the cells range:", "Kutools for Excel", xTxt, , , , , 8)
            If xRg Is Nothing Then Exit Sub
            If xRg.Areas.Count > 1 Then
            MsgBox "does not support multiple selections", vbInformation, "Kutools for Excel"
            GoTo LInput
            End If
            On Error Resume Next
            Application.ScreenUpdating = False
            xCount = xRg.Rows.Count
            For K = 1 To xRg.Columns.Count
            xColor = xRg.Cells(1, K).Interior.Color
            For I = xCount To 1 Step -1
            xRg.Cells(I, K).Interior.Color = xColor
            xRg.Cells(I, K).Interior.TintAndShade = I / xCount
            Next
            Next
            End Sub

            Please try, hope it can help you!
      • To post as a guest, your comment is unpublished.
        Daisy · 3 years ago
        How would I do this if I wanted it top left to bottom right gradient?