Automatically adding border line after a change in value in a column

jardenp

Active Member
Joined
May 12, 2009
Messages
373
Office Version
  1. 2019
  2. 2016
  3. 2013
  4. 2011
  5. 2010
Platform
  1. Windows
I've looked at a couple other posts, but haven't been able to make this work for my situation using VBA.

I want a thin border along the bottom of the cells in columns A:K whenever the value in column A changes.

So,
_A___B____C______________K__
234
234
245
245
245
267
299
299

Becomes
_A___B____C______________K_
234
234________________________
245
245
245________________________
267________________________
299
299________________________

There is a header row in 1:1 that is already formatted, so I don't want the border between rows 1 and 2 changed and, again, I'm looking for a VBA solution. Thanks!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Try:
Code:
Sub Test()
    Application.ScreenUpdating = False
    Dim LastRow As Long
    LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
    Dim rng As Range
    For Each rng In Range("A2:A" & LastRow)
        If rng <> rng.Offset(1, 0) Then
            Range("A" & rng.Row & ":K" & rng.Row).Borders(xlEdgeBottom).LineStyle = xlContinuous
        End If
    Next rng
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
Wow. That is so far beyond my VBA skills.

Works perfectly. Thank you.
 
Upvote 0

Forum statistics

Threads
1,215,022
Messages
6,122,721
Members
449,093
Latest member
Mnur

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