Simple center ? VBA

zone709

Well-known Member
Joined
Mar 1, 2016
Messages
2,129
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

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
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,224,823
Messages
6,181,182
Members
453,020
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