Macro to Format Lines Between Rows

A

adambush4242

I want to be able to go down column A in a worksheet and if the next entry is
not the same as the previous, I want to put a line between the two rows. How
would I go about doing this?

Thanks

Adam Bush
 
H

Harald Staff

Hi Adam

One way among many:

Sub test()
Dim R As Long
Dim V As Variant
V = Range("A1").Value
For R = 1 To Cells(Rows.Count, 1).End(xlUp).Row + 1
If Cells(R, 1).Value <> V Then
V = Cells(R, 1).Value
With Cells(R - 1, 1).Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Weight = xlThick
End With
End If
Next
End Sub

HTH. Best wishes Harald
"(e-mail address removed)"
 
J

Joel

Sub Addrows()

RowCount = 1
Do While Range("A" & RowCount) <> ""
If Range("A" & RowCount) <> Range("A" & (RowCount + 1)) Then
Rows(RowCount + 1).Insert
RowCount = RowCount + 2
Else
RowCount = RowCount + 1
End If
Loop

End Sub
 

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

Top