+ Reply to Thread
Results 1 to 9 of 9

Delete Columns based on a specific word

  1. #1
    Forum Contributor
    Join Date
    12-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    102

    Delete Columns based on a specific word

    What would the code be to delete a column if it contains a word such as "Time"? It can be any column.

  2. #2
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Delete Columns based on a specific word

    You said A column, so I am assuming just one column? If so

    Columns(Cells.Find("Time").Column).Delete

  3. #3
    Forum Contributor
    Join Date
    12-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    102

    Re: Delete Columns based on a specific word

    Hi,
    I just need one column. It could be several but one will work. I can run the macro for several different columns. How can I specify a specific cell with a specific word to delete the column?

  4. #4
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Delete Columns based on a specific word

    what do you mean? Can you post a sample workbook?

  5. #5
    Forum Contributor
    Join Date
    12-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    102

    Re: Delete Columns based on a specific word

    I suppose I didn't give enough infmortation lol. It needs to be set to a specific cell such as B2. That way it doesnt find the wrong cell and delete the wrong column.
    Quote Originally Posted by JieJenn View Post
    You said A column, so I am assuming just one column? If so

    Columns(Cells.Find("Time").Column).Delete

  6. #6
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Delete Columns based on a specific word


    Columns(Cells.Find(Range("B2").Column).Delete

  7. #7
    Forum Contributor
    Join Date
    12-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    102

    Re: Delete Columns based on a specific word

    What I meant is that it needs to find the word "Time" in B2 and delete that column. If that word isn't in B2 then it should leave the column as it is.

  8. #8
    Forum Expert
    Join Date
    12-15-2009
    Location
    Chicago, IL
    MS-Off Ver
    Microsoft Office 365
    Posts
    3,177

    Re: Delete Columns based on a specific word

    If Range("B2").Value = "Time" Then Columns("B").Delete

  9. #9
    Forum Contributor
    Join Date
    12-14-2012
    Location
    United States
    MS-Off Ver
    Excel 2010
    Posts
    102

    Re: Delete Columns based on a specific word

    Thanks JieJenn, exactly what I was looking for.

+ 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