Simple center ? VBA

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
2,079
Office Version
  1. 365
Platform
  1. Windows
Hi simple ? need to center first row from A1 to G1
Code:
[LEFT][COLOR=#333333][FONT=monospace].Columns("A1:G1").HorizontalAlignment = xlCenter[/FONT][/COLOR][/LEFT]
don't work

Code:
.Columns("A:G").HorizontalAlignment = xlCenter
works but centers everything from A to G

Thanks
 
Last edited:

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Try:
Code:
Range("A1:G1").HorizontalAlignment = xlCenter
 
Upvote 0
Hi simple ? need to center first row from A1 to G1
Code:
.[B][COLOR="#FF0000"]Columns[/COLOR][/B]("A1:G1").HorizontalAlignment = xlCenter[/FONT][/COLOR][/LEFT]
don't work

A1:G1 is a range, not a set of columns... try changing the keyword Columns that I highlighted in red to the keyword Range instead.
 
Last edited:
Upvote 0
Dam it should of none. Why I come here sometimes I was trying it over and over with Columns. Thanks guys
 
Upvote 0

Forum statistics

Threads
1,215,265
Messages
6,123,961
Members
449,135
Latest member
jcschafer209

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