Forced formatting of input data

Mike Welch

Board Regular
Joined
May 26, 2010
Messages
64
Platform
  1. Windows
  2. MacOS
I have a sheet that routinely has data pasted into it. Sometimes the data that is pasted in has a 13.5 pt. MS Sans Serif font. I want everything on the sheet to look uniform so I would like any text placed in the sheet to instantly convert to a 12 pt. Comic Sans font. I would think the easiest way is some code which looks for change within the sheet's cells and then issues an appropriate format command if change (data pasted in) is found. How can I code that (or is there a better solution)? [ Win XP Pro v.2002 SP3 / Excel 2003 SP3 ]

Thanks!
 

Some videos you may like

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,974
Office Version
  1. 365
Platform
  1. Windows
You can use Event Procedure VBA code, which is automatically triggered upon some event happening. Here, we can use the CHANGE event.

Simply right click on the tab name of sheet you want to apply this to, select View Code, and paste the following VBA code in the resulting window:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    With Target.Font
        .Name = "Comic Sans MS"
        .Size = 12
    End With
End Sub
This should work data either manually entered or pasted onto this sheet.

To read up more on Event Prcoedures, have a look here:
http://www.cpearson.com/excel/Events.aspx
 

Mike Welch

Board Regular
Joined
May 26, 2010
Messages
64
Platform
  1. Windows
  2. MacOS
Joe - worked perfectly, just the way I wanted - thanks!!!
Mike
 

Watch MrExcel Video

Forum statistics

Threads
1,123,452
Messages
5,601,748
Members
414,471
Latest member
cchunyadi

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
Top