ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cut a column in one line of VBA (https://www.excelbanter.com/excel-programming/274144-re-cut-column-one-line-vba.html)

Tom Ogilvy

Cut a column in one line of VBA
 
You need two command. The cut and the insert

Columns(2).Resize(,2).Cut
columns(17).Insert
You need to insert them as Q:R for them to end up being O:P.

Of course, the last time someone wanted a one line solution for two separate
command, the suggestion was
Columns(2).Resize(,2).Cut : columns(17).Insert

--
Regards,
Tom Ogilvy


"PK" wrote in message
...
Hello,

I can move a column in VBA, but the macro recorder does it
in four lines of code. To be more efficient, I'm sure it
can be accomplished in a single VBA code line.

PLEASE NOTE: I want to CUT two adjoining columns (e.g. B:C)
and MOVE them by INSERTING them into a new location (e.g.
O:P). When all is said and done, the original
columns "B:C" will be gone (i.e. the spreadsheet will have
shifted to the left to absorb the empty columns created by
cutting columns "B:C" out), and columns "O:P" will now
contain the cut data and the original data in "O" will
still be there, only shifted to the right. Can this be
accomplished in a single VBA line?

Your example code is most appreciated. Thanks in advance.





All times are GMT +1. The time now is 06:16 AM.

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