How to draw lines to seperate data

G

garrylwhiting

I would like to create a macro to automaticly insert a solid or das
line to seperate data after each change in value of any given column
As an example after the data sheet has been sorted using column A "ca
manufacture" all the Chevy, Ford, or Honda would have a solid lin
drawn under the data. Also within each group, column B "type o
vehicle", (car, pickup, SUV) would be seperated with a dash line.
would like to be able to use a User Form to select which cloumn will b
underlined using the solid line and which will column will be underline
using the dash line
 
D

Dick Kusleika

Garry

This sub does it for columns A and B. If you need help making it relative
to whatever columns are selected, post back.

Sub CreateUnderlines()

Dim rCell As Range

For Each rCell In Sheet1.Range("A1:A9").Cells
If rCell.Value <> rCell.Offset(1, 0).Value Then
Intersect(rCell.EntireRow, rCell.Parent.UsedRange) _
.Borders(xlEdgeBottom).LineStyle = xlContinuous
ElseIf rCell.Offset(0, 1).Value <> rCell.Offset(1, 1).Value Then
Intersect(rCell.EntireRow, rCell.Parent.UsedRange) _
.Borders(xlEdgeBottom).LineStyle = xlDash
End If
Next rCell

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