Conditional Formatting problem when copying using VBA and deleting Columns and Rows

johnmpc

Board Regular
Joined
Oct 19, 2020
Messages
89
Office Version
  1. 365
Platform
  1. Windows
Hi Experts,

I would like a way to keep the cell formatting from the conditional formatting performed before this range is copied.

I don't need the conditional formatting rules on the copied to sheet (email order version). just want it to appear the same as the original.

Is there a way to delete just the rules but keep the formatting?

Main area of issue is where i delete columns if they don't contain certain criteria, and i have conditional formatting set on values in a different cell.
Here's my code. Thanks for the help.

Sub MyDeleteColumns()

Dim lc As Long
Dim c As Long
Dim lr As Long

Application.ScreenUpdating = False



' Copy data from one sheet to other
Sheets("Order Template").Range("A27:F47,I27:I47,L27:M47,Q27:AF47").Copy Sheets("Email order version").Range("A14")

' Autofit columns
Sheets("Email order version").Activate
Columns("T:Y").AutoFit

' Find last column in row 1 with data (last header)
Sheets("Email order version").Activate
lc = Cells(17, Columns.Count).End(xlToLeft).Column


' Loop through all columns
For c = lc To 10 Step -1
' Check to see if last row in column is 17
If Cells(Rows.Count, c).End(xlUp).Row = 17 Then
' Delete column
Columns(c).Delete
End If
Next c




Application.ScreenUpdating = True

End Sub
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,152,034
Messages
5,767,756
Members
425,431
Latest member
Sayson

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
Top