Conditionally Adding Diagonal Border and Fill Color

TBone32

New Member
Joined
Sep 23, 2009
Messages
11
I am trying to create a printable golf scorecard. I would like to have the cells for holes where the hole handicap, row 2, are equal to or less than the players handicap, column c, to be yellow with a diagonal border, from lower left to upper right, so that the gross and net scores can be entered. This is simply for printing and no data will be directly entered. I can handle the background through conditional format but, of course, not the diagonal lines. So, if I need to do code for the diagonal border, I would prefer to handle both through code. However, my code writing is limited and it's been a while. Do any help would be appreciated. Than you for your help.

Excel 2016 (Windows) 32 bit
[Table="width:, class:head"][tr=bgcolor:#E0E0F0][th] [/th][th]
B
[/th][th]
C
[/th][th]
D
[/th][th]
E
[/th][th]
F
[/th][th]
G
[/th][/tr]
[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
1
[/td][td]
Hole​
[/td][td]
[/td][td]
1​
[/td][td]
2​
[/td][td]
3​
[/td][td]
4​
[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
2
[/td][td]
Handicap​
[/td][td]
[/td][td]
11​
[/td][td]
14​
[/td][td]
1​
[/td][td]
2​
[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
3
[/td][td]
Par​
[/td][td]
[/td][td]
4​
[/td][td]
5​
[/td][td]
3​
[/td][td]
4​
[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
4
[/td][td]
White Tee Yardage​
[/td][td]
[/td][td]
319​
[/td][td]
516​
[/td][td]
153​
[/td][td]
322​
[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
5
[/td][td]
Jeff​
[/td][td]
0​
[/td][td]
[/td][td]
[/td][td]
[/td][td]
[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
6
[/td][td]
Tim​
[/td][td]
4​
[/td][td]
[/td][td]
[/td][td=bgcolor:#FFFF00]
[/td][td=bgcolor:#FFFF00]
[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
7
[/td][td]
Mark​
[/td][td]
10​
[/td][td]
[/td][td]
[/td][td=bgcolor:#FFFF00]
[/td][td=bgcolor:#FFFF00]
[/td][/tr]


[tr=bgcolor:#FFFFFF][td=bgcolor:#E0E0F0]
8
[/td][td]
Rick​
[/td][td]
12​
[/td][td=bgcolor:#FFFF00]
[/td][td]
[/td][td=bgcolor:#FFFF00]
[/td][td=bgcolor:#FFFF00]
[/td][/tr]
[/table]
[Table="width:, class:grid"][tr][td]Sheet: Sheet8[/td][/tr][/table]
 
Last edited:

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Try this UNTESTED....
Code:
Sub MM1()
Dim r As Long, c As Long
For c = 3 To 20
    For r = 5 To 8
      If Cells(2, c) <= Cells(r, 2).Value Then
            With Cells(r, c).Interior
                .Color = 65535
            End With
            With Cells(r, c).Borders(xlDiagonalUp)
                .LineStyle = xlContinuous
                .Weight = xlThin
            End With
        End If
    Next r
    Next c
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top