how to copy and move columns?

R

ruchie

hi
i would like to know how i can move entire columns within a worksheet
itself. eg.- if i want to move column D and its entire contents, and
insert it in between column A and B, how should i go about it?
 
S

somethinglikeant

Sub MoveColumns()
Columns("D:D").Cut
Range("B1").Insert Shift:=xlToRight
End Sub

This should do the trick

I like to refer to columns using their number left to right
This example is a little more flexible

Sub MoveColumns()
x = 4 ' column to move
y = 1 'to the right of which column
Columns(x).Cut
Cells(1, y + 1).Insert Shift:=xlToRight
End Sub

change the values of x and y accordingly

http://www.excel-ant.co.uk 'underconstruction
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top