Excel VBA Columns in chart - format font, color, alignment etc

BMRobin

New Member
Joined
Feb 8, 2016
Messages
9
I am having troubles formatting columns in a chart to match a specific font, colour, alignment etc.
This code, while focused on column A:A, it applies to every single cell in the worksheet. I only want it to affect Column A:
<code style="margin: 0px; padding: 0px; border: 0px; font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif; white-space: inherit;">Sub PGMNumber()
'
' PGMNumber Macro
'

'
Range
("A:A").Select
With Selection.Font
.Name ="Arial"
.Size =10
.Strikethrough =False
.Superscript =False
.Subscript =False
.OutlineFont =False
.Shadow =False
.Underline = xlUnderlineStyleNone
.Color =-16776961
.TintAndShade =0
.ThemeFont = xlThemeFontNone
EndWith
With Selection.Font
.Name ="Arial"
.Size =10
.Strikethrough =False
.Superscript =False
.Subscript =False
.OutlineFont =False
.Shadow =False
.Underline = xlUnderlineStyleNone
.Color =-16776961
.TintAndShade =0
.ThemeFont = xlThemeFontNone
EndWith
Selection
.Font.Bold =False
Selection
.Font.Bold =True
With Selection.Font
.Color =-10477568
.TintAndShade =0
EndWith
With Selection
.HorizontalAlignment = xlLeft
.VerticalAlignment = xlBottom
.WrapText =False
.Orientation =0
.AddIndent =False
.IndentLevel =0
.ShrinkToFit =False
.ReadingOrder = xlContext
.MergeCells =False
EndWith
Columns
("A:A").ColumnWidth =9.43
EndSub</code>This was done by recording my steps. All I need is FontName, Colour, Bold, Size and Alignment. I noticed deleting what I don't need breaks the code :(
Can someone help me simplify the code so it will only affect column A?
Also, how do I add the code to include other columns, for example B, C, D, etc.
Lastly, can I have the macro start formatting from A6 downward, B6 downward, C6 downward, etc? That way the header of the chart remains untouched.
Thank you! It's so simple but I can't figure it out! Thank you for your time.
 

Excel Facts

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

Forum statistics

Threads
1,214,983
Messages
6,122,582
Members
449,089
Latest member
Motoracer88

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