Copy Condiltional Formatting using code

G

Guest

Hi,
I have a range name with few cell containing conditional formation, when I
copy that range to an other workbook using code like this, the conditional
formatting is not copied.

Range("MYRANGE").Select
Selection.SpecialCells(xlCellTypeVisible).Copy

Application.Windows(temp2).Activate
Workbooks(temp2).Worksheets("MYSHEET").Range("A1").Paste

Range("MYRANGE").Select
Selection.SpecialCells(xlCellTypeVisible).Copy

Application.Windows(temp2).Activate
Workbooks(temp2).Worksheets(MYSHEET).Range("A1").PasteSpecial
Paste:=xlPasteValues

I apreciate any help.
Thank you
 
B

Bernie Deitrick

Ben,

You need to actually paste the formatting:

Range("MYRANGE").SpecialCells(xlCellTypeVisible).Copy

'Paste Values
Workbooks(temp2).Worksheets(MYSHEET).Range("A1").PasteSpecial _
Paste:=xlPasteValues
'Paste FORMATS
Workbooks(temp2).Worksheets(MYSHEET).Range("A1").PasteSpecial _
Paste:=xlPasteFormats

HTH,
Bernie
MS Excel MVP
 
G

Guest

Thank you Bernie

Bernie Deitrick said:
Ben,

You need to actually paste the formatting:

Range("MYRANGE").SpecialCells(xlCellTypeVisible).Copy

'Paste Values
Workbooks(temp2).Worksheets(MYSHEET).Range("A1").PasteSpecial _
Paste:=xlPasteValues
'Paste FORMATS
Workbooks(temp2).Worksheets(MYSHEET).Range("A1").PasteSpecial _
Paste:=xlPasteFormats

HTH,
Bernie
MS Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top