Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

amend macro to make first row a set colour index

Posted on 2013-11-07
3
Medium Priority
?
277 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
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.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

916 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