• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to make cell pattern and colour in diagonal

p45cal

Well-Known Member
Yes, you can do nearly this with:
77637

but it has a gradual gradient which you can't change using the user interface, so it's not much good for you:
77638

However, you can make that delineation much clearer with a bit of code; you'll only have to do it with one cell once, thereafter you can delete the code (so your workbook doesn't have to be macro-enabled) and copy|Paste formats to other cells.
The code affects the selected cell(s) adds all formatting needed:
Code:
Sub blah()
With Selection.Interior
  .Pattern = xlPatternLinearGradient
  With .Gradient
    .Degree = 45
    .ColorStops.Clear
    .ColorStops.Add (0)
    .ColorStops.Add (0.49)
    With .ColorStops.Add(0.51)
      .Color = vbYellow
    End With
    With .ColorStops.Add(1)
      .Color = vbYellow
    End With
  End With
End With
Selection.Borders(xlDiagonalUp).LineStyle = xlContinuous
End Sub
Which gives:
77639
actually, the last line gives a diagonal border, leaving:
77640
and if there's a value in the cell that'll show too:
77641
 

p45cal

Well-Known Member
Is there any other options without code
No.
You only need to run the code once on one cell (or more if you want). Thereafter you can delete the code because you can copy paste formats from that cell (or any cell which has that format).
 

vletm

Excel Ninja
Kutty
If those cells are empty
... then You could add there basic shape - to get those looking cells as You would like to get.
Screenshot 2022-01-29 at 20.08.59.png
 

Kutty

Member
No. The cell have some data. If possible, then I will make the condition format to make colour the diagonal portion.
 

vletm

Excel Ninja
Kutty
Those could show datas too.
Screenshot 2022-01-30 at 09.51.57.png
It would help - if You could give more details
- what do You really would like to get?
- how would You use it?
 
Top