ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Copy format from another Workshet (https://www.excelbanter.com/excel-programming/389527-copy-format-another-workshet.html)

Nde

Copy format from another Workshet
 
Hello,

I tried to use this code to make it easy. But the macro failed at colorindex.

With Range("A:BF")
.Formula = Workbooks(ReforecastWorkbook).Sheets("ReForecast -
Detailed").Range("A:BF").Formula
.ColorIndex = Workbooks(ReforecastWorkbook).Sheets("ReForecast -
Detailed").Range("A:BF").Interior.ColorIndex
.Pattern = Workbooks(ReforecastWorkbook).Sheets("ReForecast -
Detailed").Range("A:BF").Interior.Pattern
End With

How can I combine all that ?

Nde

Dave

Copy format from another Workshet
 
You're definately on the right track here, the only thing I can see is you
need to reference the ".interior" property before the .colorindex & .pattern
..... as in
"interior.colorindex" & "interior.pattern". Likely you will need both
spreadsheets open to run the code snippet. Addressing each column as a
range may not give you the results you are looking for if each cell in the
column has different formatting in which case you may need to address each
cell individually (just not sure)
Best

"Nde" wrote:

Hello,

I tried to use this code to make it easy. But the macro failed at colorindex.

With Range("A:BF")
.Formula = Workbooks(ReforecastWorkbook).Sheets("ReForecast -
Detailed").Range("A:BF").Formula
.ColorIndex = Workbooks(ReforecastWorkbook).Sheets("ReForecast -
Detailed").Range("A:BF").Interior.ColorIndex
.Pattern = Workbooks(ReforecastWorkbook).Sheets("ReForecast -
Detailed").Range("A:BF").Interior.Pattern
End With

How can I combine all that ?

Nde


Nde

Copy format from another Workshet
 
The Macro works, but not results ! Youe guess was the good one, cells have
different format !

How can I go through each cell ?

Nde


"Dave" wrote:

You're definately on the right track here, the only thing I can see is you
need to reference the ".interior" property before the .colorindex & .pattern
.... as in
"interior.colorindex" & "interior.pattern". Likely you will need both
spreadsheets open to run the code snippet. Addressing each column as a
range may not give you the results you are looking for if each cell in the
column has different formatting in which case you may need to address each
cell individually (just not sure)
Best

"Nde" wrote:

Hello,

I tried to use this code to make it easy. But the macro failed at colorindex.

With Range("A:BF")
.Formula = Workbooks(ReforecastWorkbook).Sheets("ReForecast -
Detailed").Range("A:BF").Formula
.ColorIndex = Workbooks(ReforecastWorkbook).Sheets("ReForecast -
Detailed").Range("A:BF").Interior.ColorIndex
.Pattern = Workbooks(ReforecastWorkbook).Sheets("ReForecast -
Detailed").Range("A:BF").Interior.Pattern
End With

How can I combine all that ?

Nde



All times are GMT +1. The time now is 05:25 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com