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!
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
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
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,370
Members
449,080
Latest member
Armadillos

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