+ Reply to Thread
Results 1 to 4 of 4

Deleting Rows with a specific value from a variable column (constant title)

  1. #1
    Registered User
    Join Date
    06-01-2011
    Location
    zurich
    MS-Off Ver
    Excel 2010
    Posts
    4

    Question Deleting Rows with a specific value from a variable column (constant title)

    Dear all,

    I am trying to write a macro that deletes rows from a column (variing in position, but with a constant title "Contaminant") from a spreadsheet. I have tried to put something like this together but somehow it does not work completely:

    -First seach the column header "Contaminant"
    -Select entire column and set it a s target column for the deleting operation
    - with "for" the used range (I have set it to 20000, do not know how to specify used cells) "if" cell in "contaminant " column has value "+" then delete row.

    Does anybody know what is wrong with this code, or suggest a better way?

    Please Login or Register  to view this content.
    Last edited by seloni; 07-12-2011 at 07:29 AM.

  2. #2
    Valued Forum Contributor mohd9876's Avatar
    Join Date
    05-04-2011
    Location
    Amman, Jordan
    MS-Off Ver
    Excel 2010
    Posts
    426

    Re: Deleting Rows with a specific value from a variable column (constant title)

    I think the problem in your code if the quotations in the following line, you have to remove them and add Set statement
    Please Login or Register  to view this content.
    and also a faster way to do your task is using autofilter, try this:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert Domski's Avatar
    Join Date
    12-14-2009
    Location
    A galaxy far, far away
    MS-Off Ver
    Darth Office 2010
    Posts
    3,950

    Re: Deleting Rows with a specific value from a variable column (constant title)

    This should work looping like you were originally trying to do:

    Please Login or Register  to view this content.

    Dom
    "May the fleas of a thousand camels infest the crotch of the person who screws up your day and may their arms be too short to scratch..."

    Use code tags when posting your VBA code: [code] Your code here [/code]

    Remember, saying thanks only takes a second or two. Click the little star to give some Rep if you think an answer deserves it.

  4. #4
    Registered User
    Join Date
    06-01-2011
    Location
    zurich
    MS-Off Ver
    Excel 2010
    Posts
    4

    Re: Deleting Rows with a specific value from a variable column (constant title)

    Cheers to both!
    That works like a charm and fast.

    Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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