+ Reply to Thread
Results 1 to 3 of 3

Deleting Columns based on criteria in two rows

  1. #1
    Registered User
    Join Date
    04-20-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    12

    Deleting Columns based on criteria in two rows

    Hi,

    I have a large spreadsheet with a double header row and merged cells.

    For instance:

    Row 1: Column A, B, C is merged and has "2010" in it, Column X, Y, Z has "2011" in it.
    Row 2: Column A and X = "Plan", Column B and Y = "Released", Column C and Z = "Actual".

    I need a macro that will search Row 1 and if it = 2010 then it will delete all the columns that = "Plan", "Released", "Actual"

    The catch is this, the columns won't always be the same (it may be A, B, C then the next time it could be D, E, F etc).

    So, the macro needs to search row 1 and if it matches 2010 then it searches row 2 and if it finds Plan, Released or Actual it deletes each column.

    Hope this makes sense.

    Thanks

    Dave

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    48,454

    Re: Deleting Columns based on criteria in two rows

    A sample workbook would be helpful to put your requirements into context.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  3. #3
    Registered User
    Join Date
    04-20-2011
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    12

    Re: Deleting Columns based on criteria in two rows

    Hi,

    Thanks for your response, a sample is attached.

    I've shown the "keep" columns and the "delete" columns. This is a sample, but I *always* want to keep all the "keep" columns IF they exist, and remove the "delete" columns IF they exist as they won't always.

    The difficuty I'm having is for instance the 2010 Section (Plan, Released, Jan - Dec columns etc) vs the 2011 Section (Plan, Released, Jan - Dec Columns etc) - I want to keep all the 2011 columns, and delete the 2010 columns.

    If I just look for all the Jan - Dec columns it deletes even the ones I want to keep rather than just the 2009 or 2010 ones.

    I download this sheet daily and each day the columns that are there slightly differ.

    Hope this makes more sense.

    Thanks

    Dave.
    Attached Files Attached Files

+ 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