Copy over color pallete from one work book to another

timspin

Board Regular
Joined
Nov 18, 2002
Messages
231
Hi

I have a workbook that uses a color pallett that I have defined. Im sucking out work sheets via a macro from another workbook to another. Trouble is the worksheet I suck out is a different color (based on the original color profile)

Any ideas??

Cheers
Tim
 

Some videos you may like

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,402
Try
Code:
    ActiveWorkbook.Colors = Workbooks("originalbook.xls").Colors
 

timspin

Board Regular
Joined
Nov 18, 2002
Messages
231
Hiya

OK, Im muddling my way through this withoput really knowing what Im doing. Where would you code fit in to my code???


Dim ToBook As String
Dim ToSheet As Worksheet
Dim NumColumns As Integer
Dim ToRow As Long
Dim FromBook As String
Dim FromSheet As Worksheet
Dim FromRow As Long
Dim LastRow As Long
'-
'=========================================================
'- MAIN ROUTINE
'=========================================================
Sub FILES_FROM_FOLDER2(WEEKNO)
Application.Calculation = xlCalculationManual
ChDrive ActiveWorkbook.Path
ChDir ActiveWorkbook.Path
ToBook = ActiveWorkbook.Name
'---------------------------
'- MASTER SHEET
'---------------------------
Set ToSheet = ActiveSheet
NumColumns = ToSheet.Range("A1").End(xlToRight).Column
ToRow = ToSheet.Range("A500").End(xlUp).Row
'- clear master
If ToRow <> 1 Then
ToSheet.Range(ToSheet.Cells(2, 1), _
ToSheet.Cells(ToRow, NumColumns)).ClearContents
End If
ToRow = 2
'------------------------------------------
'- main loop to open each file in folder
'------------------------------------------
FromBook = Dir("*.xls")
While FromBook <> ""
If FromBook <> ToBook Then
Application.StatusBar = FromBook
Transfer_data2 (WEEKNO) ' subroutine below
End If
FromBook = Dir
Wend
'-- close

Application.StatusBar = False
Application.Calculation = xlCalculationAutomatic
End Sub
'


Private Sub Transfer_data2(WEEKNO2)

Workbooks.Open Filename:=FromBook
Sheets(WEEKNO2).Select
Sheets(WEEKNO2).Copy After:=Workbooks("Summary bezel.xls").Sheets(1 _
)

Workbooks(FromBook).Close savechanges:=False

End Sub
 

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,402
You are "sucking" sheets from many books ... which one is the palette supposed to come from?
 

timspin

Board Regular
Joined
Nov 18, 2002
Messages
231

ADVERTISEMENT

Hi Glen

So I have say 10 workbooks in a folder. Each of these workbooks are the same (each has the same color pallete - and its this color pallete that I want in my Big Bumper work book that sucks out all the worksheets from my ten in the folder)

Cheers
Tim
 

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,402
try putting:
Code:
    Workbooks("Summary bezel.xls").Colors = Workbooks(FromBook).Colors
before Workbooks(FromBook).Close savechanges:=False
in the Transfer_data2 routine. It'll copy the palette 10 times, but that doesn't matter ( as long as it doesn't slow your process down too much).
 

timspin

Board Regular
Joined
Nov 18, 2002
Messages
231

ADVERTISEMENT

Thats the one - cheers Glen I really appreciate your help!!!
Cheers
Tim
 

XL Pro

Board Regular
Joined
Apr 17, 2002
Messages
222
Excellent GlennUK! This is just the problem I encountered today and thanks to a simple search, I found the answer here!
 

GlennUK

Well-known Member
Joined
Jul 8, 2002
Messages
11,402
Great!

That's great! That's one of the things that makes this site so useful.

:)
 

Watch MrExcel Video

Forum statistics

Threads
1,118,226
Messages
5,570,990
Members
412,353
Latest member
SofiaV
Top