how to copy and move columns?

  • Thread starter Thread starter ruchie
  • Start date Start date
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?
 
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
 
Back
Top