Results 1 to 15 of 15

Delete Row if Contains Blank Cell

Threaded View

leahb909 Delete Row if Contains Blank... 09-21-2018, 06:45 AM
AlphaFrog Re: Delete Row if Contains... 09-21-2018, 07:41 AM
leahb909 Re: Delete Row if Contains... 09-21-2018, 07:49 AM
Arkadi Re: Delete Row if Contains... 09-21-2018, 08:11 AM
AB33 Re: Delete Row if Contains... 09-21-2018, 08:11 AM
leahb909 Re: Delete Row if Contains... 09-21-2018, 08:33 AM
AB33 Re: Delete Row if Contains... 09-21-2018, 08:53 AM
leahb909 Re: Delete Row if Contains... 09-21-2018, 08:55 AM
Arkadi Re: Delete Row if Contains... 09-21-2018, 08:57 AM
leahb909 Re: Delete Row if Contains... 09-21-2018, 08:59 AM
AB33 Re: Delete Row if Contains... 09-21-2018, 08:59 AM
leahb909 Re: Delete Row if Contains... 09-21-2018, 09:09 AM
Arkadi Re: Delete Row if Contains... 09-21-2018, 09:10 AM
leahb909 Re: Delete Row if Contains... 09-21-2018, 09:25 AM
leahb909 Re: Delete Row if Contains... 09-21-2018, 09:18 AM
  1. #1
    Registered User
    Join Date
    09-06-2018
    Location
    England
    MS-Off Ver
    Office 365
    Posts
    24

    Delete Row if Contains Blank Cell

    Hello

    Please see attachment for example data.

    I have a code that searches in column B and if the cell contains either the words "Employee" or "Overall Total:", then it deletes the entire row.

    Sub Remove_Employee_Row()
    Sheets("All Data").Activate
    row_number = 1
    
    Do
    DoEvents
    row_number = row_number + 1
    employee_name = ActiveSheet.Range("B" & row_number)
    
    If InStr(employee_name, "Employee") >= 1 Then
    ActiveSheet.Rows(row_number & ":" & row_number).Delete
    row_number = row_number - 1
    
    ElseIf InStr(employee_name, "Overall Total:") >= 1 Then
    ActiveSheet.Rows(row_number & ":" & row_number).Delete
    row_number = row_number - 1
    
    End If
    
    Loop Until employee_name = ""
    
    
    MsgBox "Completed"
    
    End Sub
    How can I edit the code so that it also deletes the row if the cell in B is blank?

    I have tried editing this line
     ElseIf InStr(employee_name, "Overall Total:") >= 1 Then
    to
    ElseIf InStr(employee_name, "">= 1 Then
    but it deletes every row on the sheet.

    Thank you in advance.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Delete Row If Cell is Blank
    By ceres in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-01-2016, 09:52 AM
  2. [SOLVED] Macro Delete Contents in 23rd corresponding cell if the cell in range is a non-blank cell
    By murtaza.khan in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-04-2014, 01:11 AM
  3. Replies: 1
    Last Post: 05-10-2012, 04:58 PM
  4. [SOLVED] To delete blank rows having blank cell in the needed raws
    By Alexander_Golinsky in forum Excel General
    Replies: 4
    Last Post: 05-04-2012, 03:11 PM
  5. Replies: 1
    Last Post: 02-17-2012, 10:11 AM
  6. Delete a row if blank cell
    By mohd21uk via OfficeKB.com in forum Excel General
    Replies: 1
    Last Post: 05-04-2006, 08:45 AM
  7. Delete a row if blank cell
    By mohd21uk via OfficeKB.com in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 04-13-2006, 11:40 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