+ Reply to Thread
Results 1 to 5 of 5

How to delete multiple columns

  1. #1
    Registered User
    Join Date
    05-07-2011
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    28

    How to delete multiple columns

    I have a CSV file that has columns from A to GC. I want to delete several of those columns that are not needed. Is there a way to create a VBA function to do this for me? I could manually delete them, but if there is a way to create a function to do this for me would be great.

    This won't be the only time I do this, so creating something portable is needed.

    Ex: Delete Col D:F, H:Z etc.

    Maybe a lookup table with the fields I want and then have VBA delete them.

    What do you all think is the easiest way to do this?

  2. #2
    Valued Forum Contributor
    Join Date
    10-17-2007
    Location
    Tasmania, Australia
    MS-Off Ver
    2019, 365(v2403)
    Posts
    370

    Re: How to delete multiple columns

    To delete columns D to F and H to Z in Excel using a macro, you can use the following VBA code:

    Please Login or Register  to view this content.
    To run this macro, follow these steps:

    Press ALT + F11 to open the Visual Basic for Applications editor.
    Insert a new module by clicking Insert > Module.
    Copy and paste the above VBA code into the module.
    Close the VBA editor.
    Press ALT + F8 to open the Macro dialog box.
    Select the "DeleteColumns" macro and click Run

  3. #3
    Registered User
    Join Date
    05-07-2011
    Location
    USA
    MS-Off Ver
    Excel 2013
    Posts
    28

    Re: How to delete multiple columns

    Thank you and this is what I thought I would have to do.

  4. #4
    Valued Forum Contributor
    Join Date
    10-17-2007
    Location
    Tasmania, Australia
    MS-Off Ver
    2019, 365(v2403)
    Posts
    370

    Re: How to delete multiple columns

    If that takes care of your original question, please choose Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank anyone who offered you help towards a solution for your issue by clicking the small star icon (* Add Reputation) located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of each of those who offered help.

  5. #5
    Forum Expert
    Join Date
    10-06-2008
    Location
    Canada
    MS-Off Ver
    2007 / 2013
    Posts
    5,722

    Re: How to delete multiple columns

    Another way of doing it.
    Select in the UF ListBox, click on the Button and live happily ever after.
    See attached
    Attached Files Attached Files
    The inherent weakness of the liberal society: a too rosy view of humanity.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Delete Duplicates in Multiple Cells & Multiple Columns
    By jennysoderquist in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-08-2017, 05:37 PM
  2. [SOLVED] Delete multiple columns in a Table
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 05-31-2016, 09:09 AM
  3. [SOLVED] Delete multiple columns based on value in first row
    By igormigor in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-11-2016, 05:32 AM
  4. Delete row if multiple columns empty
    By amadman114 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-22-2013, 06:53 AM
  5. Replies: 9
    Last Post: 12-20-2012, 10:29 AM
  6. [SOLVED] Delete multiple empty cells in multiple columns and moving data up, witout Macros
    By CoraF in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-30-2012, 08:23 AM
  7. Delete multiple columns by column name no criteria need, just delete them
    By duugg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-24-2009, 10:40 AM

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