Adding row with border

Thehunk71

New Member
Joined
Apr 1, 2006
Messages
35
Office Version
  1. 365
have a sheet with large amounts of data trying to add a row with a border or double line when the series of values change in column a.
Here is what i have and it works great for adding the row but i cant figure out how to add the border or the double line.
Thanks for your help!

With Sheets("Consolidate")
lr = .Range("A" & .Rows.Count).End(xlUp).Row
For i = lr To 2 Step -1
If Len(.Range("A" & i).Value) > 0 And Len(.Range("A" & i - 1).Value) > 0 Then
If .Range("A" & i).Value <> .Range("A" & i - 1).Value Then
.Rows(i).Insert Shift:=xlDown
End If
End If
Next
End With
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
How's this?

Just change the Columns as required

Code:
With Sheets("Consolidate")lr = .Range("A" & .Rows.Count).End(xlUp).Row
For i = lr To 2 Step -1
If Len(.Range("A" & i).Value) > 0 And Len(.Range("A" & i - 1).Value) > 0 Then
If .Range("A" & i).Value <> .Range("A" & i - 1).Value Then
.Rows(i).Insert Shift:=xlDown
.Rows(i - 1).Columns("A:B").Select
    With Selection.Borders(xlEdgeBottom)
        .LineStyle = xlDouble
        .ColorIndex = 0
        .TintAndShade = 0
    End With
End If
End If
Next
End With
 
Upvote 0
Does this help?
Code:
Sub SetRangeBorder() 
    With Worksheets("Sheet1").Range("B2").Borders(xlEdgeBottom) 'you can resize the range to your needs.
       .LineStyle = xlContinuous 
       .Weight = xlThick 
       .ColorIndex = xlAutomatic
    End With 
    With Worksheets("Sheet1").Range("B3").Borders(xlEdgeBottom) 
       .LineStyle = xlDouble 
       .Weight = xlMedium 
       .ColorIndex = xlAutomatic 
 End With 
End Sub
 
Last edited:
Upvote 0
AWSOME! Thank you both!!
that has me going in a direction. I will try to figure the rest out on my own!
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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