Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

amend macro to make first row a set colour index

Posted on 2013-11-07
3
255 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
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 demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

791 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