Add Borderlines

  • Thread starter Thread starter Curious
  • Start date Start date
C

Curious

I want to try to "box" the same customer by adding top border line and
bottom border line. I just want to improve readability for fun.

A long data list looks like

AAAAA
AAAAA
BBBBB
CCCCC
CCCCC
CCCCC

Any ideas or codes to share?

Thanks in advance

H. Z.
 
This will add a thick bottom border at each change of customer.

Sub Border_At_Change()
Dim LastRow As Long
Dim X As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
Application.ScreenUpdating = False

For X = LastRow To 3 Step -1
If Cells(X, 1).Value <> Cells(X - 1, 1).Value Then
If Cells(X, 1).Value <> "" Then
If Cells(X - 1, 1).Value <> "" Then
With Cells(X - 1, 1).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = xlAutomatic
End With
End If
End If
End If
Next X
Application.ScreenUpdating = True
End Sub


Gord Dibben MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top