Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Apply Format Settings From Worksheet to all other Sheets in Workbook

Posted on 2016-08-03
5
Medium Priority
?
56 Views
Last Modified: 2016-08-04
I have a worksheet in a workbook that is used as a baseline and has specific formatting.  Is there simple code in vba to read the formatting :Text size, column size, row size, fonts, print settings, etc  from my baseline sheet and apply it to all other worksheets in the workbook?
0
Comment
Question by:robbdfw
[X]
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
5 Comments
 
LVL 12

Expert Comment

by:tel2
ID: 41741555
Hi robbdfw,

I don't know about the VBA option, but have you tried:
- Selecting the entire baseline sheet (i.e. click just to the left of the "A" header and above the "1" header).
- Click the format painter.
- Select the sheets you want to reformat (e.g. click the 1st sheet tab, hold down shift and click the last in the range).
- On the sheet that's now showing, again click just to the left of the "A" header and above the "1" header to apply that format to all selected sheets.
- Check the formats have changed on the required sheets.

Seems to work for me in Excel 2007 except I don't think it's copying print areas (if that's what you mean by "print settings" - is it?).
0
 
LVL 33

Accepted Solution

by:
Subodh Tiwari (Neeraj) earned 2000 total points
ID: 41741728
You may try something like this.....

Sub CopyFormat()
Dim sws As Worksheet, ws As Worksheet
Set sws = Sheets("Sheet1")   'Source sheet with formatting to be copied to other sheets in the workbook
sws.Cells.Copy
For Each ws In Worksheets
    If ws.Name <> sws.Name Then
        ws.Range("A1").PasteSpecial xlPasteFormats
    End If
Next ws
End Sub

Open in new window

0
 
LVL 22

Expert Comment

by:Roy Cox
ID: 41741814
It's faster to simply select all the sheets rather than Loop through them. The active sheet would have it's formats overwritten but they would remain the same anyway. You can change ActiveSheet to a specific sheet e.g. Sheet1.Copy

Sub CopyFormat()


ActiveSheet.Cells.Copy

Worksheets.Select
Range("A1").PasteSpecial xlPasteFormats
Range("A1").PasteSpecial xlPasteColumnWidths
End Sub

Open in new window

0
 

Author Closing Comment

by:robbdfw
ID: 41743453
Thank you.  Great help as always.
0
 
LVL 33

Expert Comment

by:Subodh Tiwari (Neeraj)
ID: 41743641
You're welcome. Glad to help.
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
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…

618 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