Matching cell formatting

cbcrocker

Board Regular
Joined
Feb 10, 2010
Messages
50
Is there a way to automatically change a cell's formatting when the formatting of another cell is changed?
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
you can do this trick

suppose the cell which has format is G1 and the cell to which this format is to be changed is C1.

now open vbeditor
hit control+R
you get project window on the left containing all the open workbooks
goto this particular workbook and under this right click "thisworkbook" (if necesary click the minus sign on the left of the workbook name)
clcik view code

in the window that comes up copy this EVENT CODE

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Range("G1").Copy
Range("c1").PasteSpecial Paste:=xlPasteFormats
End Sub
(MODIFY the code to suit you)

now change the format of G1 to whatever you want
hit control+S to save the file
C1 also will change to the same format as in G1
 
Upvote 0
Okay, it works from a template BUT, each time I save it goes to the target cells. Is there a way for it to position to cell A1 after it changes the formatting of the target cells?
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,626
Members
452,933
Latest member
patv

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