+ Reply to Thread
Results 1 to 7 of 7

Delete multiple columns based on value in first row

  1. #1
    Forum Contributor
    Join Date
    01-18-2013
    Location
    Prague
    MS-Off Ver
    Excel 2013
    Posts
    161

    Delete multiple columns based on value in first row

    Hi all,

    I have big table with many columns. From those columns I need to keep only several. The rest I need to delete. Can anyone help me with a macro which will delete all necessary columns.

    The table I have is in sheet “Table”, columns A to ZZ. The number of rows can vary. Column names are in the first row (A1:ZZ1).
    The list with all column names that I need to keep is in the sheet “Required columns”, range A1:A12.

    Thank you in advance for your help.

    Igor

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete multiple columns based on value in first row

    Can you provide the list in Sheet "Required Columns" ?

  3. #3
    Forum Expert sourabhg98's Avatar
    Join Date
    10-22-2014
    Location
    New Delhi, India
    MS-Off Ver
    Excel 2007, 2013
    Posts
    1,899

    Re: Delete multiple columns based on value in first row

    Assuming you have data in Sheet named >> Data
    and list in Sheet named >> List
    Use this macro-
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Happy to Help

    How to upload excel workbooks at this forum - http://www.excelforum.com/the-water-...his-forum.html

    "I don't get things easily, so please be precise and elaborate"

    If someone's post has helped you, thank by clicking on "Add Reputation" below the post.
    If your query is resolved please mark the thread as "Solved" from the "Thread Tools" above.

    Sourabh

  4. #4
    Forum Contributor
    Join Date
    01-18-2013
    Location
    Prague
    MS-Off Ver
    Excel 2013
    Posts
    161

    Re: Delete multiple columns based on value in first row

    Hi Sourabhg98,
    The code works good, but I need to keep the columns that are in the list.
    If there is column which is not in the list, then to delete it.
    Thank you!
    Igor

  5. #5
    Forum Contributor
    Join Date
    01-18-2013
    Location
    Prague
    MS-Off Ver
    Excel 2013
    Posts
    161

    Re: Delete multiple columns based on value in first row

    Hi JOHN H. DAVIS,
    The list is not fixed. It can change over time. Please use the example that Sourabhg98 shared.
    Igor

  6. #6
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Delete multiple columns based on value in first row

    Maybe:

    Please Login or Register  to view this content.
    Depending on your Sheet's formatting.

  7. #7
    Forum Contributor
    Join Date
    01-18-2013
    Location
    Prague
    MS-Off Ver
    Excel 2013
    Posts
    161

    Re: Delete multiple columns based on value in first row

    your code did not worked fully. I've made some changes. Its little messy, but it works.

    Thank you JOHN H. DAVIS and Sourabhg98 for your help.

    Please Login or Register  to view this content.

+ 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 rows based on the value of two columns using VBA code - Multiple worksheets
    By OmniBlue in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-18-2015, 04:24 PM
  2. [SOLVED] Delete row based on text criteria in multiple columns
    By Jim885 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-23-2015, 12:16 AM
  3. Find and Delete rows based on criteria in multiple columns
    By Doctor_H in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-01-2013, 08:03 PM
  4. [SOLVED] how to delete data in two columns based on multiple criteria?
    By marreco in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-21-2013, 09:01 PM
  5. [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
  6. Macro to delete certain columns and delete rows based on time in another column
    By beepbeep27 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-12-2012, 11:47 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

Tags for this Thread

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