How do I fix this??
In Excel, we can easily fill background color to a cell or multiple cells, but, sometimes, we need the color be filled gradient as following screenshot shown, how could get the color gradient in a cell or across multiple cells in Excel?
|Color gradient to one cell||Color gradient across to multiple cells|
In Excel, the Format Cells feature can help you to fill the color gradient in one cell, please do as follows:
1. Select a cell or multiple cells that you want to be filled with color gradient each cell, and then right click to choose Format Cells from the context menu, in the Format Cells dialog box, under the Fill tab, please click Fill Effects button, see screenshot:
2. In the Fill Effects dialog, select two colors that you want to use from the two drop down lists of Colors section, and then select one shading styles as you like, such as horizontal, Vertical, and so on. See screenshot:
3. Then click OK > OK to close the dialogs, and the gradient color is filled for each cell as following screenshot shown:
The above method can help us to color gradient within individual cell, if you need to shade the color gradient across multiple cells, you need apply a VBA code to solve it.
1. First, fill a specific background color to a range of cells.
2. Hold down the ALT + F11 keys to open the Microsoft Visual Basic for Applications window.
3. Click Insert > Module, and paste the following code in the Module Window.
VBA code: Apply gradient color across multiple cells:
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. Then press F5 key to run this code, and a prompt box is appeared to remind you selecting the colored cells that you want to fill gradient color, see screenshot:
5. And then click OK button, the color within multiple cells has displayed as gradient color, see screenshot: