Force text in cell to center & middle align

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,738
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

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
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,223,903
Messages
6,175,289
Members
452,631
Latest member
a_potato

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