Listing The Various Properties Associated with the Border Object

Sub BorderLineStyles() Dim rg As Range

Set rg = ThisWorkbook.Worksheets("Borders"). _ Range("LineStyleListStart").Offset(1, 0)

Do Until IsEmpty(rg)

rg.Offset(0, 2).Borders(xlEdgeBottom).LineStyle = rg.Offset(0, 1).Value


Set rg = Nothing

End Sub

You've seen a number of examples in this chapter that follow this pattern, so there is not a whole lot to talk about here. This procedure operates on a worksheet named Borders. In particular it is looking for a range named LineStyleListStart, which I have defined as cell A12 in Figure 10.8 below. The output of BorderLineStyles is shown in Figure 10.8.

It just dawned on me that by looping though a range like this to demonstrate all of the various choices available for the properties you've been looking at, I haven't made it very clear how you use the defined constants. I wouldn't want to lead you to believe that you have to get the value of the constant before using it. So, to make it clear, Listing 10.6 demonstrates an alternate way to write Listing 10.5.

0 0

Post a comment