+ Reply to Thread
Results 1 to 4 of 4

How can I delete rows based on specific criteria using a macro?

  1. #1
    Registered User
    Join Date
    11-23-2011
    Location
    Phoenix, Arizona
    MS-Off Ver
    Excel 2007
    Posts
    3

    How can I delete rows based on specific criteria using a macro?

    Hi. I'm new to this forum so I'll get straight to the point. I need a macro that can go through all cells between P2 and P25000 and if the value is equal to 1 in any cell then I would like the entire row of this cell to be deleted. If the value is NOT equal to 1 then I don't need it to do anything. The name of my workbook is called "Historical Data" and I want this macro to run on "Sheet 2". If anyone could please write a specific code that I could simply copy and paste it into a new module without any editing I would greatly appreciate it as I'm not a programmer! Please use the data I provided here to create the code. As for the name of the macro please use "Test1". I definitively need a macro for this as doing it manually is not an option for me. Thank you very much for all your help!

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,168

    Re: How can I delete rows based on specific criteria using a macro?

    Hi akouleze and welcome to the forum,

    Try this code from the sheet you want to remove all rows that have 1 in column P.
    Please Login or Register  to view this content.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    11-23-2011
    Location
    Phoenix, Arizona
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: How can I delete rows based on specific criteria using a macro?

    Thank you very much MarvinP!!!! It works great and really fast!!!

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: How can I delete rows based on specific criteria using a macro?

    If the data is in a table format then automating AutoFilter would be fastr than a Loop
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

+ 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