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
B
C
D
E
F
G
1
Hole​
1​
2​
3​
4​
2
Handicap​
11​
14​
1​
2​
3
Par​
4​
5​
3​
4​
4
White Tee Yardage​
319​
516​
153​
322​
5
Jeff​
0​
6
Tim​
4​
7
Mark​
10​
8
Rick​
12​
Sheet: Sheet8
 
Last edited:

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
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,214,936
Messages
6,122,340
Members
449,079
Latest member
rocketslinger

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