Centering

LeeHitchen

New Member
Joined
Mar 20, 2002
Messages
26
Hi All

Does anyone know of a way of automatically Centre-aligning text in each row each time you open a new worksheet?.

ta

Lee
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Sir Vili

Board Regular
Joined
Jul 11, 2002
Messages
148
Hello LeeHitchen.

Here is simple code:

Sub Center_All_Cols()
Cells.Select
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
Range("A1").Select
End Sub

Sub Auto_Open()
Center_All_Cols
End Sub

Copy it from here on Module and save. Next time when opening Workbook all columns are Centre-aligning.

Best Regards Sir Vili.
 

LeeHitchen

New Member
Joined
Mar 20, 2002
Messages
26
Sir Vili

Where do I place it so everytime I create a new workbook they are all Centre aligned. Sorry to sound naive....but I am!
 

Sir Vili

Board Regular
Joined
Jul 11, 2002
Messages
148
Sorry I did not read carefully Your question. When opening a new workbook, then take keyboard command ALT F11. Then from Menu Insert Module and copy this code.

I think this the only way to do. Maybe others can help You more.

By the way there are no silly questions, but about answers I do not know. Just kidding :wink:

Sir Vili.
 

PaddyD

MrExcel MVP
Joined
May 1, 2002
Messages
14,234
Another option:

1) Open up a new workbook.
2) Go to Format | Styles...Click modify
3) Select the Alignment tab & pick the options you want as the defaults for your workbook. click OK etc...
4) Enter some text to see the effect.

So, the issue now is how to get this default setup to apply to all your new workbooks. As styles are one of the things that can be stored in templates, one answer would be to save the workbook as a template (*.xlt) and base future workbooks on that template. See the help topics on:

'Settings Microsoft Excel can save in a template'

'Customize the defaults for a workbook or worksheet by using a template'

etc.

Paddy
 

Forum statistics

Threads
1,143,919
Messages
5,721,536
Members
422,369
Latest member
redinator

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