+ Reply to Thread
Results 1 to 5 of 5

Macro code to delete entire row if cell in column A is equal to a value

  1. #1
    Registered User
    Join Date
    12-02-2013
    Location
    London
    MS-Off Ver
    Excel 2010
    Posts
    19

    Macro code to delete entire row if cell in column A is equal to a value

    I need an easy code that searches all of column A and deletes the entire row if the cell has the value "-". It needs to find the last row of data using something like LastRow = Range("A" & Rows.Count).End(xlUp).Row

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,810

    Re: Macro code to delete entire row if cell in column A is equal to a value

    try this:

    Please Login or Register  to view this content.
    Last edited by alansidman; 05-07-2014 at 02:53 PM.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Macro code to delete entire row if cell in column A is equal to a value

    Please Login or Register  to view this content.

  4. #4
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Macro code to delete entire row if cell in column A is equal to a value

    Quote Originally Posted by alansidman View Post
    try this:

    Please Login or Register  to view this content.
    If you are going to loop, loop backwards otherwise the row pointer can get thrown.

  5. #5
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,810

    Re: Macro code to delete entire row if cell in column A is equal to a value

    Thanks Bob,

    I was just trying to type faster than you can bring things up from OneNote.

    Per Bob's suggestion, replace this line in my code

    Please Login or Register  to view this content.
    with

    Please Login or Register  to view this content.
    My oversight. Thanks Bob for pointing that out.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro code to delete entire row if the cell in column C = 0
    By glock9mm in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-18-2013, 02:50 PM
  2. [SOLVED] Macro to delete entire row (within a specified range) if cell in column A is empty
    By instinctellekt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-07-2012, 10:01 AM
  3. Macro (Delete Entire row Cell in column R is empty)
    By andrewvt in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-20-2011, 07:06 AM
  4. Macro to delete entire rows where O2:O does not equal a date
    By rain4u in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-20-2011, 10:37 PM
  5. Delete Entire Row When Cell Not Equal
    By ajocius in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-09-2009, 02:23 AM

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