Shift range of cells on active row left or right

Zoops

New Member
Joined
May 25, 2018
Messages
2
Hi all,

I'm having a bit of a nightmare here. I have what is essentially a planner: First five columns are static data and then I have thirteen empty columns. After that I have a number of hours per week for the entire year, and then another thirteen empty columns, and calculation columns after

What I really need is a macro that I can run on the row of the active cell that will copy everything in the empty cells and number of hours, and either shift it one cell left or right without affecting the first five columns or the calculation columns.

TL:DR
To make it a bit easier, how can I make a macro that will cut everything on the active row only, between columns AB:DC
and then paste it either one cell to the left or right

It sounds like it should be very easy but for the life of me I can't figure it out.
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
This will move the active cell row between AB:DC left or right depending on what you want

Code:
Sub MoveRow()
'
Set SRange = range("AB" & ActiveCell.Row)
Set ERange = range("DC" & ActiveCell.Row)
Set SERange = range(SRange, ERange)

SERange.Cut Destination:=SERange.Offset(0, -1) ' Move Left Once
' OR
SERange.Cut Destination:=SERange.Offset(0, 1) ' Move Right Once

End Sub
 
Upvote 0
That is absolutely brilliant thanks very much! I didn't think of just putting & ActiveCell.Row... I kept trying to declare another variable as ActiveCell.Row and then putting that in. Silly me
 
Upvote 0

Forum statistics

Threads
1,224,825
Messages
6,181,189
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