How to draw the line by macro?

Hi,
 I have one excel file which has Detail tab. It has Total Amount column. Now i need to draw the line if the first few row total becomes more than 50000. I need to draw the line on that Raw where sum of Total Amount > 50000.

Is there any way by conditional formatting or by macro?Example_Drawline.xlsx
Share PointAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You may try something like this...
Sub DrawLine()
Dim lr As Long, i As Long
Dim Total As Double

lr = Cells(Rows.Count, 3).End(xlUp).Row
For i = 2 To lr
    Range("A" & i & ":C" & i).Borders(xlEdgeBottom).LineStyle = xlNone
Next i
For i = 2 To lr
    Total = Total + Cells(i, 3)
    If Total > 50000 Then
        With Range("A" & i & ":C" & i).Borders(xlEdgeBottom)
            .LineStyle = xlContinuous
            .Weight = xlThick
            .Color = RGB(246, 174, 132)
        End With
        Exit Sub
    End If
Next i
End Sub

Open in new window

Example_Drawline.xlsm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Share PointAuthor Commented:
Thanks a lot Neeraj. That's  what i was looking for.
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.