Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / May 2008

Tip: Looking for answers? Try searching our database.

Cut and paste columns programmatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David Portwood - 26 May 2008 01:39 GMT
Can I get some help coding something like the following:

If Range("E1").value = "YTD" then
   'cut columns E, F, G
   'paste columns E, F, G in front of column B
end if

Basically I want to swap three YTD columns to the front. I know how to grab
one column, Range("E1").EntireColumn, for instance, but how do I grab two
more adjacent columns? Or do I have two cut and paste three times?

I won't know in advance how many rows there might be.

Thanks in advance,
David Portwood
Alan - 26 May 2008 04:21 GMT
Using the macro recorder will show you what you want but it won't be as clean
as this:

   If Range("E1").value = "YTD" then
       Columns("E:G").Cut
       Columns("B:B").Insert Shift:=xlToRight
   End If

Alan

> Can I get some help coding something like the following:
>
[quoted text clipped - 11 lines]
> Thanks in advance,
> David Portwood
David Portwood - 26 May 2008 07:25 GMT
Perfect! I was hoping there would be something simple and direct just like
this. Thank you, Alan.

> Using the macro recorder will show you what you want but it won't be as
> clean
[quoted text clipped - 23 lines]
>> Thanks in advance,
>> David Portwood
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.