Shift/realign cell values quickly

angelicawalter

New Member
Joined
Aug 21, 2017
Messages
4
I received a employee file where the data was formatted differently than how I need for the report I am creating.
I essentially need the cells to shift columns to realign to the right.

The report currently looks something like this:

A B C D
C D
D

and I need to create something that looks like:

A B C D
C D
D

Any help would be greatly appreciated.
Thanks!
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
To Clarify:

I am looking at employee data. Its employee hierarchy data.

So my data is currently structured like:

mgr dir cfo ceo
dir cfo ceo
ceo

and I need it to be shifted so that the ceo is in a single column:

ceo cfo dir mgr
ceo cfo dir
ceo

or

ceo cfo dir mgr
ceo cfo dir
ceo
 
Upvote 0
Perhaps this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG21Aug46
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, Temp [COLOR="Navy"]As[/COLOR] Variant, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Lst [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    Lst = Cells(Dn.Row, Columns.Count).End(xlToLeft).Column
    Temp = Dn.Resize(, Lst).Value
    [COLOR="Navy"]If[/COLOR] Lst > 1 [COLOR="Navy"]Then[/COLOR]
        [COLOR="Navy"]For[/COLOR] n = UBound(Temp, 2) To 1 [COLOR="Navy"]Step[/COLOR] -1
            Dn.Offset(, Lst - n) = Temp(1, n)
        [COLOR="Navy"]Next[/COLOR] n
    [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
perhaps this:-
Rich (BB code):
sub mg21aug46
dim rng as range, dn as range, temp as variant, n as long
dim lst as integer
set rng = range(range("a1"), range("a" & rows.count).end(xlup))
for each dn in rng
    lst = cells(dn.row, columns.count).end(xltoleft).column
    temp = dn.resize(, lst).value
    if lst > 1 then
        for n = ubound(temp, 2) to 1 step -1
            dn.offset(, lst - n) = temp(1, n)
        next n
    end if
next dn
end sub
regards mick

you are amazing. Thank you so much.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,327
Members
452,635
Latest member
laura12345

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