VBA code for sheet formatting

ChristineJ

Well-known Member
Joined
May 18, 2009
Messages
761
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

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
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,215,097
Messages
6,123,076
Members
449,094
Latest member
mystic19

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