ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to copy and move columns? (https://www.excelbanter.com/excel-programming/368165-how-copy-move-columns.html)

ruchie

how to copy and move columns?
 
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?


ruchie

how to copy and move columns?
 
i forgot to mention.. i have to use macros for that purpose


Tom Ogilvy

how to copy and move columns?
 
columns(4).Cut Columns(2)


--
Regards,
Tom Ogilvy


"ruchie" wrote:

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?



somethinglikeant

how to copy and move columns?
 
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

ruchie wrote:
i forgot to mention.. i have to use macros for that purpose



ruchie

how to copy and move columns?
 
thanks!!
that helped!



All times are GMT +1. The time now is 01:38 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com