Macro-thick Box Border

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,561
Office Version
  1. 2021
Platform
  1. Windows
I have a macro that inserts text "Total in Column A three rows after the last item and totals up the value in Col E three rows after the last value

I have would like to add code that will put a thick box border starting where the text Total has been inserted up to Col E in line with the word Total

I have written code to do put a thick box border around total aright up to the total value in Col E, but it does nothing. The code that inserts the text "Total" in Col A and the Value in Col E is correct.

Your assistance will be most appreciated

Finalrow = Range("A65536").End(xlUp).Row
Range("A" & Finalrow + 1).Resize(12, 12).ClearContents
Range("A" & Finalrow + 3).Value = "Total Value"
Range("E" & Finalrow + 3).Formula = "=sum(E3:E" & Finalrow & ")"

Range("A1").Select
With Range("D:D")
.TextToColumns Destination:=Range("D1"), DataType:=xlFixedWidth, _
FieldInfo:=Array(0, 1), TrailingMinusNumbers:=True
End With

Range("E" & Finalrow + 3).NumberFormat = "#,##0.00;(#,##0.00)"
Range("A" & Finalrow + 3).Resize(, 5).Font.Bold = True


Range("A" & Finalrow).Resize(, 5).Borders(xlDiagonalDown).LineStyle = xlNone
Range("A" & Finalrow).Resize(, 5).Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeTop)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
With Selection.Borders(xlEdgeRight)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlMedium
End With
Selection.Borders(xlInsideVertical).LineStyle = xlNone
Selection.Borders(xlInsideHorizontal).LineStyle = xlNone

End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Try this:
Code:
Finalrow = Range("A" & Rows.Count).End(xlUp).Row
Range("A" & Finalrow + 1).Resize(12, 12).ClearContents

With Range("E" & Finalrow + 3)
    .Formula = "=SUM(E3:E" & Finalrow & ")"
    .NumberFormat = "#,##0.00;(#,##0.00)"
End With

With Range("A" & Finalrow + 3)
    .Value = "Total Value"
    .Resize(, 5).Font.Bold = True
    .Resize(, 5).Borders = xlMedium
    .Resize(, 5).Borders(xlInsideVertical).LineStyle = xlNone
End With

Range("D:D").TextToColumns Destination:=Range("D1"), DataType:=xlFixedWidth, _
        FieldInfo:=Array(0, 1), TrailingMinusNumbers:=True
 
Upvote 0
Hi Jerry

Thanks for the help,much appreciated. Code nicely streamlined

I made one small change to your code

.Resize(, 5).Borders = xlMedium should be .Resize(, 5).Borders.weight = xlMedium
 
Upvote 0
No Problem-good that you tested me

Once again thanks for your assistance
 
Upvote 0

Forum statistics

Threads
1,213,484
Messages
6,113,920
Members
448,533
Latest member
thietbibeboiwasaco

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