VBA to copy Conditional Formatting

AndyJUK

New Member
Joined
Nov 5, 2008
Messages
9
I have a sheet with a series of tables and other information, I have created the following macro to add a new column to one of the tables and to adjust the formatting of the sheet:-

Sub AddNewWeek()
'

Columns("J:J").Select
Selection.Insert Shift:=xlToRight
Selection.ColumnWidth = 9.43
Range("K23").Select
Application.Goto Reference:="R23C11:R1000C11"
ActiveWindow.ScrollRow = 22
ActiveWindow.ScrollRow = 21
ActiveWindow.ScrollRow = 20
ActiveWindow.ScrollRow = 19
ActiveWindow.ScrollRow = 18
ActiveWindow.ScrollRow = 17
Selection.Cut Destination:=Range("J23:J1000")
Range("L23").Select
Application.Goto Reference:="R23C12:R1000C12"
Selection.Cut Destination:=Range("K23:K1000")
Range("K23:K1000").Select
ActiveWindow.SmallScroll Down:=-22
Range("K5").Select
Selection.AutoFill Destination:=Range("J5:K5"), Type:=xlFillDefault
Range("J5:K5").Select
Range("K17").Select
Selection.AutoFill Destination:=Range("J17:K17"), Type:=xlFillDefault
Range("J17:K17").Select
Range("J18").Select
ActiveCell.FormulaR1C1 = "=SUM(20-R[-1]C)"
Range("A1").Select
End Sub


I also need the macro to copy the conditional formatting rules into the newly inserted cells - at the moment the new cells are just blank.

The conditionally formatted cells are J7:J16 - The macro copies these cells to column K (same row numbers).

The conditional formatting rules are:-

1. Cell Value is Equal to "2" Fill Colour is Green
2. Cell Value is Not Equal to "2" Fill Colour is Red

Is there something I can add so the macro will do this?

Thanks in advance for any help!

Andy
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.

Forum statistics

Threads
1,216,350
Messages
6,130,139
Members
449,560
Latest member
mattstan2012

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