Applying Conditional formatting to newly inserted rows in a table

stroffso

Board Regular
Joined
Jul 12, 2016
Messages
160
Office Version
  1. 365
Platform
  1. Windows
I have some code below which inserts rows into a table. However the table has codnitional formatting in there and when I add the rows it loses the conditional format, is there some code I can add to the below that adds the conditional formatting to the rows that have just been inserted, or if it helps I just need to copy the formatting in row 8 to the newly inserted rows, thanks

Sub Insert_Rows()
'Modified 6/20/18 3:00 AM EDT
Application.ScreenUpdating = False
'Dim ans As String
'Dim anss As string
ans = InputBox("Insert row starting on row ??")
If ans = "" Then MsgBox "You entered no row to start on" & vbNewLine & " I will now stop this script": Exit Sub
anss = InputBox("Insert how many rows ??")
If anss = "" Then MsgBox "You entered no number of rows to insert" & vbNewLine & " I will now stop this script": Exit Sub
Rows(ans).Resize(anss).Insert
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Anyone got any ideas on this one?

I have some code below which inserts rows into a table. However the table has codnitional formatting in there and when I add the rows it loses the conditional format, is there some code I can add to the below that adds the conditional formatting to the rows that have just been inserted, or if it helps I just need to copy the formatting in row 8 to the newly inserted rows, thanks

Sub Insert_Rows()
'Modified 6/20/18 3:00 AM EDT
Application.ScreenUpdating = False
'Dim ans As String
'Dim anss As string
ans = InputBox("Insert row starting on row ??")
If ans = "" Then MsgBox "You entered no row to start on" & vbNewLine & " I will now stop this script": Exit Sub
anss = InputBox("Insert how many rows ??")
If anss = "" Then MsgBox "You entered no number of rows to insert" & vbNewLine & " I will now stop this script": Exit Sub
Rows(ans).Resize(anss).Insert
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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