Μετάβαση στο κύριο περιεχόμενο

Πώς να εφαρμόσετε χρωματική διαβάθμιση σε πολλά κελιά;

Στο Excel, μπορούμε εύκολα να γεμίσουμε το χρώμα του φόντου σε ένα κελί ή σε πολλά κελιά, αλλά, μερικές φορές, χρειαζόμαστε την κλίση του χρώματος όπως φαίνεται στο παρακάτω στιγμιότυπο οθόνης, πώς θα μπορούσε να πάρει τη χρωματική κλίση σε ένα κελί ή σε πολλά κελιά στο Excel;

Διαβάθμιση χρώματος σε ένα κελί Διαβάθμιση χρώματος σε πολλά κελιά
ντεγκραντέ χρώματος doc 1 ντεγκραντέ χρώματος doc 2

Εφαρμόστε χρώμα διαβάθμισης σε ένα κελί με τη λειτουργία Format Cells

Εφαρμόστε το χρώμα διαβάθμισης σε πολλά κελιά με κώδικα VBA


βέλος μπλε δεξιά φούσκα Εφαρμόστε χρώμα διαβάθμισης σε ένα κελί με τη λειτουργία Format Cells

Στο Excel, η δυνατότητα "Μορφοποίηση κελιών" μπορεί να σας βοηθήσει να συμπληρώσετε τη χρωματική διαβάθμιση σε ένα κελί, κάντε τα εξής:

1. Επιλέξτε ένα κελί ή πολλά κελιά που θέλετε να γεμίσετε με χρωματική διαβάθμιση κάθε κελιού και, στη συνέχεια, κάντε δεξί κλικ για να επιλέξετε κύτταρα μορφή από το μενού περιβάλλοντος, στο κύτταρα μορφή πλαίσιο διαλόγου, κάτω από το Γέμισμα καρτέλα, κάντε κλικ Γεμίστε εφέ κουμπί, δείτε το στιγμιότυπο οθόνης:

ντεγκραντέ χρώματος doc 3

2. Στην Γεμίστε εφέ διαλόγου, επιλέξτε δύο χρώματα που θέλετε να χρησιμοποιήσετε από τις δύο αναπτυσσόμενες λίστες του Χρωματιστά ενότητα και, στη συνέχεια, επιλέξτε ένα στυλ σκίασης όπως θέλετε, όπως οριζόντια, Κάθετα και ούτω καθεξής. Δείτε το στιγμιότυπο οθόνης:

ντεγκραντέ χρώματος doc 4

3. Στη συνέχεια κάντε κλικ στο κουμπί OK > OK για να κλείσετε τους διαλόγους και το χρώμα κλίσης συμπληρώνεται για κάθε κελί όπως φαίνεται το ακόλουθο στιγμιότυπο οθόνης:

ντεγκραντέ χρώματος doc 5


βέλος μπλε δεξιά φούσκα Εφαρμόστε το χρώμα διαβάθμισης σε πολλά κελιά με κώδικα VBA

Η παραπάνω μέθοδος μπορεί να μας βοηθήσει να χρωματίσουμε την κλίση μέσα σε μεμονωμένα κελιά, εάν πρέπει να σκιάσουμε τη χρωματική διαβάθμιση σε πολλά κελιά, πρέπει να εφαρμόσεις έναν κωδικό VBA για να το λύσεις.

1. Αρχικά, συμπληρώστε ένα συγκεκριμένο χρώμα φόντου σε μια σειρά κελιών.

2. Κρατήστε πατημένο το ALT + F11 για να ανοίξετε το Microsoft Visual Basic για εφαρμογές παράθυρο.

3. Κλίκ Κύριο θέμα > Μονάδα μέτρησηςκαι επικολλήστε τον ακόλουθο κώδικα στο Μονάδα μέτρησης Παράθυρο.

Κωδικός VBA: Εφαρμογή χρώματος διαβάθμισης σε πολλά κελιά:

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. Στη συνέχεια πατήστε F5 για να εκτελέσετε αυτόν τον κώδικα και εμφανίζεται ένα πλαίσιο προτροπής που σας υπενθυμίζει ότι επιλέγετε τα χρωματιστά κελιά που θέλετε να συμπληρώσετε το χρώμα κλίσης, δείτε το στιγμιότυπο οθόνης

 

ντεγκραντέ χρώματος doc 6

5. Και στη συνέχεια κάντε κλικ στο κουμπί OK κουμπί, το χρώμα σε πολλά κελιά έχει εμφανιστεί ως χρώμα διαβάθμισης, δείτε το στιγμιότυπο οθόνης:

 

ντεγκραντέ χρώματος doc 7

Τα καλύτερα εργαλεία παραγωγικότητας γραφείου

🤖 Kutools AI Aide: Επανάσταση στην ανάλυση δεδομένων με βάση: Ευφυής Εκτέλεση   |  Δημιουργία κώδικα  |  Δημιουργία προσαρμοσμένων τύπων  |  Αναλύστε δεδομένα και δημιουργήστε γραφήματα  |  Επίκληση Λειτουργιών Kutools...
Δημοφιλή χαρακτηριστικά: Εύρεση, επισήμανση ή αναγνώριση διπλότυπων   |  Διαγραφή κενών γραμμών   |  Συνδυάστε στήλες ή κελιά χωρίς απώλεια δεδομένων   |   Γύρος χωρίς φόρμουλα ...
Σούπερ Αναζήτηση: VLookup πολλαπλών κριτηρίων    VLookup πολλαπλών τιμών  |   VLookup σε πολλά φύλλα   |   Ασαφής αναζήτηση ....
Σύνθετη αναπτυσσόμενη λίστα: Γρήγορη δημιουργία αναπτυσσόμενης λίστας   |  Εξαρτημένη αναπτυσσόμενη λίστα   |  Πολλαπλή αναπτυσσόμενη λίστα ....
Διαχειριστής στήλης: Προσθέστε έναν συγκεκριμένο αριθμό στηλών  |  Μετακίνηση στηλών  |  Εναλλαγή κατάστασης ορατότητας κρυφών στηλών  |  Συγκρίνετε εύρη και στήλες ...
Επιλεγμένα Χαρακτηριστικά: Εστίαση πλέγματος   |  Προβολή σχεδίου   |   Μεγάλη Formula Bar    Διαχείριση βιβλίου εργασίας & φύλλου   |  Βιβλιοθήκη πόρων (Αυτόματο κείμενο)   |  Επιλογή ημερομηνίας   |  Συνδυάστε φύλλα εργασίας   |  Κρυπτογράφηση/Αποκρυπτογράφηση κελιών    Αποστολή email ανά λίστα   |  Σούπερ φίλτρο   |   Ειδικό φίλτρο (φίλτρο με έντονη γραφή/πλάγια γραφή/διαγραφή...) ...
Κορυφαία 15 σύνολα εργαλείων12 Κείμενο Εργαλεία (Προσθήκη κειμένου, Κατάργηση χαρακτήρων, ...)   |   50 + Διάγραμμα Τύποι (Gantt διάγραμμα, ...)   |   40+ Πρακτικό ΜΑΘΗΜΑΤΙΚΟΙ τυποι (Υπολογίστε την ηλικία με βάση τα γενέθλια, ...)   |   19 Εισαγωγή Εργαλεία (Εισαγωγή κωδικού QR, Εισαγωγή εικόνας από το μονοπάτι, ...)   |   12 Μετατροπή Εργαλεία (Αριθμοί σε λέξεις, Μετατροπή Συναλλάγματος, ...)   |   7 Συγχώνευση & διαχωρισμός Εργαλεία (Σύνθετες σειρές συνδυασμού, Διαίρεση κελιών, ...)   |   ... κι αλλα

Αυξήστε τις δεξιότητές σας στο Excel με τα Kutools για Excel και απολαύστε την αποτελεσματικότητα όπως ποτέ πριν. Το Kutools για Excel προσφέρει πάνω από 300 προηγμένες δυνατότητες για την ενίσχυση της παραγωγικότητας και την εξοικονόμηση χρόνου.  Κάντε κλικ εδώ για να αποκτήσετε τη δυνατότητα που χρειάζεστε περισσότερο...

Περιγραφή


Το Office Tab φέρνει τη διεπαφή με καρτέλες στο Office και κάνει την εργασία σας πολύ πιο εύκολη

  • Ενεργοποίηση επεξεργασίας και ανάγνωσης καρτελών σε Word, Excel, PowerPoint, Publisher, Access, Visio και Project.
  • Ανοίξτε και δημιουργήστε πολλά έγγραφα σε νέες καρτέλες του ίδιου παραθύρου και όχι σε νέα παράθυρα.
  • Αυξάνει την παραγωγικότητά σας κατά 50% και μειώνει εκατοντάδες κλικ του ποντικιού για εσάς κάθε μέρα!
Comments (24)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Thanks for the awesome code.

How do I make the gradient go from colour to white top to bottom?
How would i choose between two colours?
This comment was minimized by the moderator on the site
Hello, Tra,
For the first question, to make the gradient go from color to white top to bottom, please apply the following 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


For the second question, to fill the gradient with two colors, please apply the belwo code:
Note: to change the two colors, you just need to change the RGB in the code.
Sub colorgradientmultiplecells()
    'Updateby Extendoffcie
    Dim xRg As Range
    Dim xTxt As String
    Dim xCell As Range
    Dim xColor1 As Long
    Dim xColor2 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
    xColor1 = RGB(255, 0, 0) ' Red color
    xColor2 = RGB(0, 0, 255) ' Blue color
    For K = 1 To xRg.Columns.Count
        For I = xCount To 1 Step -1
            xRg.Cells(I, K).Interior.Color = RGB( _
                Int((xCount - (I - 1)) / xCount * (xColor2 Mod 256) + (I - 1) / xCount * (xColor1 Mod 256)), _
                Int((xCount - (I - 1)) / xCount * ((xColor2 \ 256) Mod 256) + (I - 1) / xCount * ((xColor1 \ 256) Mod 256)), _
                Int((xCount - (I - 1)) / xCount * (xColor2 \ 65536) + (I - 1) / xCount * (xColor1 \ 65536)))
        Next
    Next
    Application.ScreenUpdating = True
End Sub


Please have a try, hope them can help you!
This comment was minimized by the moderator on the site
Hallo,

Ich habe zu erst den ersten code verwendet, das funktioniert aber leider nicht. der färbt nur einzelne Zellen und die in komplett anderen Farben. Der Code für dunkel oben nach hell unten funktioniert gar nicht bei mir. Da kommt immer ein Syntax Error. Gibt es noch andere möglichkeiten einen Farbverlauf über mehrere Zellen zu erschaffen oder gibt es da eine andere Lösung für mich?

Vielen lieben Dank vorab schon mal.
This comment was minimized by the moderator on the site
Hello, How can I aply this formula for two colors, above I can't watch de solution. Please
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
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!
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
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!
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
Why I got Black-White color replace my gradient
This comment was minimized by the moderator on the site
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!
This comment was minimized by the moderator on the site
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!
This comment was minimized by the moderator on the site
hey, I'm not that used to VBA codes. How do I set another color in the code?
This comment was minimized by the moderator on the site
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.
This comment was minimized by the moderator on the site
thanks! it works :)
This comment was minimized by the moderator on the site
How do I get this to have the gradient go left to right?
This comment was minimized by the moderator on the site
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!
This comment was minimized by the moderator on the site
How can I make the code to go it from right to left, Thanks in advance
This comment was minimized by the moderator on the site
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
This comment was minimized by the moderator on the site
Is it possible to perform this gradient but from bottom left to top right?
This comment was minimized by the moderator on the site
Is it possible to post a code that does gradient from top to bottom? I would really appreciate it.
This comment was minimized by the moderator on the site
I would need the code from the darkest shade at the top to the lighter shade at the bottom as well.. :(
This comment was minimized by the moderator on the site
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!
This comment was minimized by the moderator on the site
How would I do this if I wanted it top left to bottom right gradient?
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations