VBA code for sheet formatting

ChristineJ

Well-known Member
Joined
May 18, 2009
Messages
756
Office Version
  1. 365
Platform
  1. Windows
I formatted a worksheet with font colors, borders, changes to columns widths and row heights, and other basic formatting things.

Are those formatting changes saved somewhere in the sheet/file in VBA code so if I sent that code to someone else they could run it and have those formatting changes applied to their sheet?

Thanks!
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
In theory, if you had the macro recorder turned on while you were reformatting the worksheet, you could send that code. I'm not aware of any other mechanism where formatting changes to a worksheet are preserved in VBA. But I'm not certain I understand your question.
 
Upvote 0
The formatting that you applied is saved. On the sheet that was formatted.

This code will take the formatting from [Workbook1.xlsm]Sheet1 and apply it to the ActiveSheet.

Code:
Sub DuplicateFormat()
    Workbooks("Workbook1.xlsm").Sheets("Sheet1").Cells.Copy

    ActiveSheet.Cells.PasteSpecial Paste:=xlFormats, Operation:=xlNone, SkipBlanks:= _
        False, Transpose:=False

    Application.CutCopyMode = False
End Sub
 
Upvote 0
Thanks to you both. I'm actually looking to send the code as if I had recorded a macro of all the formatting, which I may have to do.
 
Upvote 0

Forum statistics

Threads
1,213,538
Messages
6,114,217
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top