Shift Cells Right if Blank - to Right Justify All Cells

ktla111

New Member
Joined
Dec 14, 2017
Messages
2
Hello --

I am looking for an efficient VBA solution to arrange the cells of my data so that all of the data is aligned to the right-most cell.

In the example below, the numbers are in column A and I would like those to stay in A and I would like all of the z's to be align in column M, the c's is Column L, the a's or b's in column K, etc while the remaining cells/columns are blank. (The alignment will be independent of the content in the cell - I have only used the same content for simplicity here.)



11acz
22bcz
33cz
44cz
55cz
66z

<colgroup><col width="64" span="7" style="width: 48pt;"></colgroup><tbody>
</tbody>

Thank you in advance!!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
What range is the data in now? Are there always a max of 3 values in each row (other than column A)? If not, how many would be the max values in each row?
 
Upvote 0
The actual data that I want to "right justify" is in columns E through BD. Each column could contain data - so 52 is the max number that could be shifted, but it will vary and it is unlikely that any rows have 52 columns populated. I want to keep A:D in those respective columns.

I can work around this by forcing certain cells to not be blank, but ideally, it is slightly more complicated. If AX is not blank, I want the data in AW through AZ shifted to BA:BD. If AT is not blank I want AS:AV shifted to AW:AZ. And so on, following the same pattern.
 
Upvote 0

Forum statistics

Threads
1,215,514
Messages
6,125,267
Members
449,219
Latest member
daynle

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