HorizontalAlignment only works in immediate window

asrich

New Member
Joined
Nov 5, 2009
Messages
6
Hi all,

I have the following code

Range(Output).Offset(0,1).Value = "to"
Range(Output).Offset(0,1).HorizontalOffset = xlCenter.

There is a bunch of code after this. Everything works fine until it gets to the HorizontalOffset statement. Then the sub stops running with no error. The text does not get centered.

This doesn't work either:

Range("B1").Value = "to"
Range("B1").HorizontalOffset = xlCenter.

Also tried it in a With

With Range(Output).Offset(0,1)
.Value = "to"
.HorizontalAlignment = xlCenter
End With

Yet, if I go to the immediate window and type Range("B1").HorizontalAlignment = xlCenter

Then the text gets centered.

Andy ideas what is going on?
 

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