Do I have to put every cells range in separate line, like this
Range("A6:B" & Cells.SpecialCells(xlCellTypeLastCell).Row).HorizontalAlignment = xlLeft
Range("G6:H" & Cells.SpecialCells(xlCellTypeLastCell).Row).HorizontalAlignment = xlLeft
or can I somehow include groups of columns (from certain cell all the way down) that are not next to each other in a single line? This code below doesn't seem to work for me.
Range("A6:B,G6:H" & Cells.SpecialCells(xlCellTypeLastCell).Row).HorizontalAlignment = xlLeft
You can use Union
:
Union(Range("A6:B" & Cells.SpecialCells(xlCellTypeLastCell).Row), Range("G6:H" & Cells.SpecialCells(xlCellTypeLastCell).Row)).HorizontalAlignment = xlLeft
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments