+ Reply to Thread
Results 1 to 8 of 8

eliminate unwanted columns

Hybrid View

  1. #1
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    eliminate unwanted columns

    Hi.

    I need a macro to eliminate some columns and organize my spreadsheet.
    where I have a spreadsheet with many columns, but I need only the columns {11,12,16,30,34,41,60,61,82}, this spreadsheet, the rest of the columns should be deleted.
    and I also need to line 7 becomes the header
    See my file in
    http://www.sendspace.com/file/xpyys5

    can anyone help me?

    thank you!
    Last edited by marreco; 10-03-2012 at 08:30 PM.
    "No xadrez nem sempre a menor dist?ncia entre dois pontos ? uma linha reta" G. Kasparov.

    If your problem is solved, please say so clearly, and mark your thread as Solved: Click the Edit button on your first post in the thread, Click Go Advanced, select b from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Edit button will not appear -- ask a moderator to mark it.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: eliminate unwanted columns

    Sub m()
        Dim iCol As Long
        
        With ActiveSheet
            .Rows("1:6").Delete
            For iCol = .UsedRange.Column + .UsedRange.Columns.Count To 1 Step -1
                If IsError(Application.Match(iCol, Array(11, 12, 16, 30, 34, 41, 60, 61, 82), 0)) Then
                    .Columns(iCol).Delete
                End If
            Next iCol
        End With
    End Sub
    Last edited by shg; 10-02-2012 at 07:38 PM.
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: eliminate unwanted columns

    hello shg , you did not understand my post?

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: eliminate unwanted columns

    Hi marreco

    This response is offensive (to me)...shg is among the most brilliant participants in the Forum
    hello shg , you did not understand my post?
    please rephrase it.
    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.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: eliminate unwanted columns

    Gosh, John, thank you, but no offense taken.

    In fairness to marreco, I posted a completely incorrect answer, realized that a minute or two later, edited it to a nonsensical "....^....1", and then reposted. Marreco responded before my last edit.
    Last edited by shg; 10-03-2012 at 10:27 AM.

  6. #6
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: eliminate unwanted columns

    @ marreco
    My apologies. I've dealt with you A LOT on this Forum and have never known you to be rude. I should have known there was something I wasn't seeing.

    @ shg
    Thanks for setting me straight...hopefully next time I won't shoot from the hip.

  7. #7
    Valued Forum Contributor marreco's Avatar
    Join Date
    07-02-2011
    Location
    Brazil
    MS-Off Ver
    Excel 2010
    Posts
    1,862

    Re: eliminate unwanted columns

    Hi

    there's been a misunderstanding.

    I just asked a question, the reason was because when I opened it and saw the response of the master SHG, it was written ("^ 1 ......"), then I innocently asked the question.

    I did not mean to offend anyone!

    I would never do that, after all everyone here helped me and still help me!

    please excuses and you understand that!

    please forgive me but I had no such intention.

  8. #8
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: eliminate unwanted columns

    Hi marreco

    No apology necessary...it was MY mistake...shg explained to me.

    Again
    My apologies. I've dealt with you A LOT on this Forum and have never known you to be rude. I should have known there was something I wasn't seeing.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1