Question:
How to Merge & Center in Excel quickly down a column?
Tinkerbell
2008-05-28 09:34:59 UTC
I often have to merge and center two columns in Excel, I discovered how to create a macro, but I still have to go row by row. Is there a faster way to go down two columns and keep all the rows separate, yet merge just the columns? If I highlight several rows, it all merges in to one cell.
Five answers:
five v
2008-05-28 10:04:36 UTC
If you record a macro (merging 2 cells) you get something like this:



Range("A1:B1").Select

With Selection

.HorizontalAlignment = xlCenter

.VerticalAlignment = xlBottom

.WrapText = False

.Orientation = 0

.AddIndent = False

.IndentLevel = 0

.ShrinkToFit = False

.ReadingOrder = xlContext

.MergeCells = False

End With

Selection.Merge



You can modify this to do the same thing down the columns for as many cells as you like:



Dim i As Integer



For i = 1 To 100

With Range("A" + CStr(i) + ":B" + CStr(i))

.HorizontalAlignment = xlCenter

.MergeCells = True

End With

Next i



Note that I left only the horizontal alignment and merge cells instructions, the rest are irrelevant. The only major difference is that now instead of having only 1 row merged, the row is determined by hte value of "i", which loops from 1 to 100.



If you don't have a consistent number of rows in the column, you might want to replace the "100" above with the number of non-empty rows:



Dim i As Integer

Dim RowCnt as Integer



''''''''''''COUNT ALL THE NON-EMPTY ROWS IN COLUMN A

RowCnt = Application. _

WorkSheetFunction.CountA( _

Range("A:A"))



''''''''''''MAKE THE ROW COUNT THE UPPER LIMIT FOR "i"

For i = 1 To RowCnt

With Range("A" + CStr(i) + ":B" + CStr(i))

.HorizontalAlignment = xlCenter

.MergeCells = True

End With

Next i
deguire
2016-11-06 03:22:11 UTC
Merge And Center The Selected Cells
?
2016-05-28 17:47:55 UTC
Yes you can do that... Just highlight all the rows or columns that you want to merge, then hit merge button... You can merge and center hundreds of rows and columns if you want... Good luck!
unnga
2008-05-28 11:45:05 UTC
Why don't you make the column bigger and then simply center it?



You should also be aware that it is tedious to undo it in order to do simply copy and paste.
Mike P
2008-05-28 09:43:29 UTC
HAVE YOU TRIED...

...TO MERGE & CENTER ONE COLUMN...

...SELECT & COPY THAT MERGED COLUMN...

...SELECT THE COLUMNS YOU WANT MERGED...

...THEN PASTE?



I HAVE EXCEL 2002 AT WORK AND DOING THE ABOVE THINGS WORKED FOR ME.



HOPE THAT HELPS!


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...