Adding Borders To Cells Of Inserted Rows

Ark68

Well-known Member
Joined
Mar 23, 2004
Messages
4,564
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have this code that inserts blank rows to size the overall table to fill a page.

Rich (BB code):
               With va
                    .Activate
                    markrow = Application.WorksheetFunction.Match("mark", .Range("A1:A200"), 0)
                    llrow = markrow + 4
                    For Each q In .Range("A1:A" & llrow)
                        ptrh = ptrh + q.Height
                    Next q
                    diff = dph - ptrh
                    rta = WorksheetFunction.RoundDown((diff / 12.75), 0)
                    MsgBox "Default page height:   579.75 pts" & Chr(13) & "Current page height:   " & ptrh & " pts" & Chr(13) & "Difference:   " & diff & " pts" & Chr(13) & "Rows to add:   " & rta
                    If rta > 0 Then
                        a_pda = WorksheetFunction.RoundDown((0.6 * rta), 0)
                        a_fma = rta - a_pda
                        fmarow = Application.WorksheetFunction.Match("Facility Maintenance Activities", .Range("A1:A200"), 0)
                        lrow_pda = fmarow - 3
                        Set ac = ActiveSheet.Cells(lrow_pda, 1)
                        For add_apda = 1 To a_pda
                            ac.offset(add_apda).EntireRow.Insert
                        Next add_apda
                        .Range("H" & lrow_pda + 1 & ":Q" & lrow_pda + a_pda).Interior.ColorIndex = RGB(0, 0, 0)
                        fmarow = Application.WorksheetFunction.Match("mark", .Range("A1:A200"), 0)
                        lrow_fma = fmarow - 1
                        Set ac = ActiveSheet.Cells(lrow_fma, 1)
                        For add_afma = 1 To a_fma
                            ac.offset(add_afma).EntireRow.Insert
                        Next add_afma
                    End If
                    On Error Resume Next
                    .Range("A" & lrow_fma + a_fma) = ""
                    On Error GoTo 0
                    gh1 = Application.WorksheetFunction.Match("mark", .Range("A:A"), 0)
                    .Range("A" & gh1) = ""
                End With

Th code inblue is doing the actual adding. I have no problem with the concept.
The problem I am having is with borders.
The table cells are bordered with extrathin black lines top and bottom and thin lines to the left and right.
After the lines are inserted, I am missing extrathin lines in the range for which the rows were inserted. The range of cells in column B that don't have the extrathin horizontal borders always fall directly under a merged cell.

https://image.ibb.co/jriuQk/30_04.jpg

What code could I use, and where can I add it, to return the horizontal line to the cells missing them.

I see these maybe used ...

Rich (BB code):
 .LineStyle = xlContinuous 
 .Weight = xlThin 
 .ColorIndex = 1
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,215,461
Messages
6,124,954
Members
449,198
Latest member
MhammadishaqKhan

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