Force text in cell to center & middle align

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,832
Office Version
  1. 2007
Platform
  1. Windows
I wish to have the text Center & Middle Aligned regardless of what the icon on taskbar shows.

I have tried the below but made no difference, also where on the sheet should it be placed as i placed it in worksheet change

VBA Code:
     With Range("G13:G18")
     .VerticalAlignment = xlCenter
     End With
 

Attachments

  • EaseUS_2024_10_ 8_13_55_52.jpg
    EaseUS_2024_10_ 8_13_55_52.jpg
    30.3 KB · Views: 2

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Where should it be placed? It depends on what you want it to do. If you put it in Worksheet_Change it will be applied every time there is input to any cell in the worksheet.

"regardless of what the icon on taskbar shows" This doesn't really make sense because the icons on the Ribbon will match whatever is applied to the cell, as you can see in my demo below.

This worked fine for me:
VBA Code:
   With Range("G13:G18")
      .VerticalAlignment = xlVAlignCenter
      .HorizontalAlignment = xlHAlignCenter
   End With


Before:
1728395269664.png


After:

1728395294305.png
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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