Hi,
I need a macro that will delete all columns except 5 columns that I identify by Header Name.
Please help on this.
Thanks,
Vikas
Hi,
I need a macro that will delete all columns except 5 columns that I identify by Header Name.
Please help on this.
Thanks,
Vikas
Last edited by VKR; 01-07-2013 at 09:56 AM.
I know there must be a better way.
![]()
Sub VKR() For Each rcell In Range("A1:Z1") If rcell <> "AA" Then If rcell <> "BB" Then If rcell <> "CC" Then If rcell <> "DD" Then If rcell <> "EE" Then rcell.EntireColumn.Delete xlToLeft End If End If End If End If End If Next rcell End Sub
Replace the letters with your Header names and expand the Columns range to suit
Hi Vikas
See this link...the code does just as you describe...if you need help adapting let me know
http://www.vbforums.com/showthread.p...delete-columns
John
If you have issues with Code I've provided, I appreciate your feedback.
In the event Code provided resolves your issue, please mark your Thread as SOLVED.
If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.
It works...Thanks to both..![]()
To VKR you're welcome.
To jaslake. No problems from me. It a good policy and learning experience to see different ways to solve problems.
@Vikas
You're welcome...glad I could help. Thanks for the Rep.
@JOHN H. DAVIS
There's always more than one way.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks