+ Reply to Thread
Results 1 to 12 of 12

Delete columns based on cell criteria

  1. #1
    Forum Contributor
    Join Date
    12-03-2009
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    184

    Delete columns based on cell criteria

    Hello All,

    I'm using the attached code (thanks to someone on this site) to delete a column based on whether a set characters exist in row 2. This currently looks for the letters "FP1". How would I make this work to look for FP1, FP2, FP3, FP4. I don't want to look for all of them, just one, so if any of them exist, delete the column.

    tx

    E.

    Please Login or Register  to view this content.
    Last edited by enhydra; 04-19-2011 at 09:05 PM.

  2. #2
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Delete columns based on cell criteria

    try:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Delete columns based on cell criteria

    hi, enhydra, please check attachment, run code "test"
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    12-03-2009
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    184

    Re: Delete columns based on cell criteria

    Thanks tlafferty, it deletes the first column with FP1 but then it doesn't delete the columns with FP2 FP3 or FP4.

    E.

  5. #5
    Valued Forum Contributor tlafferty's Avatar
    Join Date
    04-08-2011
    Location
    United States, Tacoma, WA
    MS-Off Ver
    Excel 2010, Excel 2013 Customer Preview
    Posts
    1,112

    Re: Delete columns based on cell criteria

    Hmmm....have you looked at watersev's attached solution?

  6. #6
    Forum Contributor
    Join Date
    12-03-2009
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    184

    Re: Delete columns based on cell criteria

    Yes, I was just trying it out and it seems to work.

    E.

  7. #7
    Forum Contributor
    Join Date
    12-03-2009
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    184

    Re: Delete columns based on cell criteria

    Thanks watersev.

    E.

  8. #8
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: Delete columns based on cell criteria

    hi, enhydra, though you marked the thread as Solved and I know that the code is not right, I will post "excuse me" file and code attached that is working correctly.
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    04-07-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    22

    Re: Delete columns based on cell criteria

    you may want to Use an autofilter function filter for what you want to delete, then use the special cells function to delete all visable cells, you then loop it to address your next criteria, i.e. GoTo first and re use the code with a new criteria. This is a much faster way then going row by row and individualy deleting each row. If you want an example I'll post one for you.

  10. #10
    Registered User
    Join Date
    10-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Delete columns based on cell criteria

    Enhydra or Watersev, could you please post the code from the excel file in this forum. For some reason I cannot open the excel file at work. Later I will also try to open it from my pc at home. Thank you.

  11. #11
    Forum Expert
    Join Date
    12-10-2006
    Location
    Sydney
    MS-Off Ver
    Office 365
    Posts
    3,525

    Re: Delete columns based on cell criteria

    Hi peleonsi,

    Though it's against forum rules to ask a question in a thread that's not your own, as it's just to get the solution here's watersev's code from post 8:

    Please Login or Register  to view this content.
    HTH

    Robert
    ____________________________________________
    Please ensure you mark your thread as Solved once it is. Click here to see how
    If this post helps, please don't forget to say thanks by clicking the star icon in the bottom left-hand corner of my post

  12. #12
    Registered User
    Join Date
    10-30-2013
    Location
    United States
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Delete columns based on cell criteria

    Thank you, and sorry. I will review the forum rules.

+ 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