Solved

amend macro to make first row a set colour index

Posted on 2013-11-07
3
232 Views
Last Modified: 2013-11-07
Hi Expert's

how would I amend the current macro so when each sheet is copied it retain the olour index in row 1...

range a1:t1. And colour index 33 background colour with white font txt..

Sub SplitWorkbook() Dim sht As Worksheet For Each sht In ThisWorkbook.Sheets If sht.Name <> "main" Then sht.Copy With ActiveSheet.Cells .Copy .PasteSpecial Paste:=xlPasteValues .PasteSpecial Paste:=xlPasteFormats End With ActiveWorkbook.SaveAs Filename:="C:\my documents\team\mi\new\" & sht.Name & ".xls" ActiveWorkbook.Close savechanges:=False End If Next sht End Sub

Open in new window

0
Comment
Question by:route217
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
etech0 earned 500 total points
Comment Utility
I'm not exactly sure what you're looking for, but try this:

Sub SplitWorkbook() 
Dim sht As Worksheet 
For Each sht In ThisWorkbook.Sheets 
	If sht.Name <> "main" Then 
		sht.Copy 
		With ActiveSheet.Cells 
			.Copy 
			.PasteSpecial Paste:=xlPasteValuesAndNumberFormats
		End With 
		ActiveWorkbook.SaveAs Filename:="C:\my documents\team\mi\new\" & sht.Name & ".xls" 
		ActiveWorkbook.Close savechanges:=False 
	End If 
Next sht 
End Sub

Open in new window

0
 

Author Comment

by:route217
Comment Utility
Eteco

thanks for the feedback. ..works fine
0
 
LVL 10

Expert Comment

by:etech0
Comment Utility
Glad to help!

BTW: I'm not sure if line 5 (sht.Copy) does anything, so you might want to try deleting it and see if the macro still works.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Improved? Move/Copy Add-in Replacement - How to avoid the annoying, “A formula or sheet you want to move or copy contains the name XXX, which already exists on the destination worksheet.” David Miller (dlmille)  It was one of those days… I wa…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now