Solved

amend macro to make first row a set colour index

Posted on 2013-11-07
3
252 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
ID: 39630288
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
ID: 39630294
Eteco

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

Expert Comment

by:etech0
ID: 39630301
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
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 two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

777 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