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

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
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.
 
Upvote 0
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!
 
Upvote 0
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.
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,853
Members
449,051
Latest member
excelquestion515

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