VBA Identify number in column and underline border in row

jakobt

Active Member
Joined
May 31, 2010
Messages
337
I have a table with account codes in column A. The accounts are 4 digits between 1000-9000. But not all accounts are used
After Account 3999 I want to insert a thick border underline in that row.

I want to develop a macro which can identify which row is below account 3999 and insert a thick border line in column A to column AA.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Will this do?

Code:
Option ExplicitDim LastRowNo As Long
Dim ACloop As Long


Sub AcUnderline()
LastRowNo = Range("A65536").End(xlUp).Row


If LastRowNo > 1 Then
    For ACloop = 1 To LastRowNo
        If Range("A" & ACloop).Value > 3999 Then
                With Range("A" & ACloop & ":AA" & ACloop).Borders(xlEdgeBottom)
        .LineStyle = xlContinuous
        .ColorIndex = xlAutomatic
        .TintAndShade = 0
        .Weight = xlThick
    End With
        End If
    Next ACloop
End If
End Sub
 
Upvote 0
That's clever. It needs a return after option explicit. The dim should be on another line
 
Upvote 0
Thanks great nearly there.

It inserts a boarder under each account after 3999. However the intention is just to insert a border under the row with account 3999.

For now all accounts above 3999 has a border highlight.
 
Upvote 0
You could stick an "Exit For" after the "End With" which will stop after the find and underline.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,178
Members
453,021
Latest member
Justyna P

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