• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Use a VBA script to for all text with a range you select

Dear all,


I'm looking for a macro with which I can select a certain part of a sheet, then press a short key and then for the selecter area for a certain format (for example times new roman 12).


Anybody some input on a script I can use for this?


Dear regards,


Marc
 
Marc


This is a great way to learn about how macro's work


Use the Macro recorder and record the steps you want to take


You will get something like

[pre]
Code:
Sub Macro1()
Range("B2:C4").Select
Selection.Font.Bold = True
With Selection.Font
.Name = "Arial"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Selection.Font.Size = 12
End Sub
Then replace the hard coded ranges with Selection


Sub Marc1()
Selection.Font.Bold = True
With Selection.Font
.Name = "Arial"
.Size = 11
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ThemeColor = xlThemeColorLight1
.TintAndShade = 0
.ThemeFont = xlThemeFontNone
End With
Selection.Font.Size = 12
End Sub
[/pre]
You can now assign it to a Custom icon on a Custom ToolBar
 
Alternatively you can setup your own Cell Styles


goto the Drop Down arrow next to the Cell Styles on the Home Tab

New Cell Style

Design your own style and save it
 
Back
Top