PDA

View Full Version : Solved: extend the border line until desired row



Yjmmay34
07-29-2010, 07:25 PM
Hi, all.
i need a macro to help me extend the border line until "GLOBAL ACCOUNTS Total ". how should i write a macro to do it automatically?? pls check the attachment.
thank you!
and i used to extend the border line use the code below, but this is to extend the bottom line. Then how about the attachment i attached below? how should i edit the code?


GrandTotalRowCount = 0
i = 1
Do While ActiveSheet.Cells(i, 1) <> "GLOBAL ACCOUNTS Total"
GrandTotalRowCount = GrandTotalRowCount + 1
i = i + 1
Loop
GrandTotalRowCount = GrandTotalRowCount + 1
For k = 1 To GrandTotalRowCount
If Cells(k, "A").Borders(xlEdgeBottom).LineStyle <> xlNone Then
With Cells(k, "A").Resize(, 26).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = xlAutomatic
End With
End If
Next k

khushii
07-29-2010, 11:46 PM
Hi, all.
i need a macro to help me extend the border line until "GLOBAL ACCOUNTS Total ".

Hi,
Try this Code..

It extends border until "GLOBAL ACCOUNTS Total "
Sub Borderline()
GrandTotalRowCount = 0
i = 1
Do While ActiveSheet.Cells(i, 1) <> "GLOBAL ACCOUNTS Total"
GrandTotalRowCount = GrandTotalRowCount + 1
i = i + 1
Loop
GrandTotalRowCount = GrandTotalRowCount + 1

For k = 1 To GrandTotalRowCount
With Cells(k, "A").Resize(, 26).Borders
.LineStyle = xlCountinuous
.ColorIndex = xlAutomatic
.Weight = xlThin
End With

Next k
End Sub

Yjmmay34
08-02-2010, 12:59 AM
Thank you khushii. Your code is working perfectly.