Conditional Borders through a Macro

  • Thread starter Thread starter MSchmidty2
  • Start date Start date
No, your description was fine... my last post telling you to ignore this
code crossed with the message I am now responding to. I am quite hopeful
that this code will do what you want...

Sub Demo()
Dim R As Range
Dim C As Range
Dim Prev As Range
Dim X As Integer
Dim LastRow As Long
Dim StartRow As Long
StartRow = 2
With Worksheets("Sheet1")
LastRow = .Cells(Rows.Count, "A").End(xlUp).Row
Set R = Intersect(.Rows().SpecialCells(xlCellTypeVisible), _
.Range("A" & StartRow & ":A" & LastRow))
Set Prev = .Cells(LastRow + 1, "A")
For Each C In R
If C.Value <> Prev.Value Then
With C.Resize(1, 27).Borders(xlEdgeTop)
.LineStyle = xlContinuous
.Weight = xlThick
.ColorIndex = 9
End With
End If
Set Prev = C
Next
End With
End Sub
 
Thank you, Rick. It works perfectly. I appreciate your help and expertise,
and your patience. I look forward to figuring out why it works, too! Again,
Thanks.
 
If you have any question remaining after you try to figure out what my code
it doing, please feel free to post back here and ask.
 

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