• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

Spreadsheet has column A:R. I want to delete entire row if column A is blank

I have a spreadsheet that has columns A through R.  Columns A,B,C contain a users name.  If column A is blank then I would like to delete the entire row and keep only the rows that have data in Column A (no last name,delete row)
Column A = LastName
               B = FirstName
               C=  MIDNAME

The other columns contain business information.  So if there is no user attached to this business, then delete the entire row.
0
kvrogers
Asked:
kvrogers
  • 2
1 Solution
 
ThomasMcA2Commented:
Does the solution have to use VBA? If the solution does not need to be done every day, it's much easier to use built-in functions:

1) Enable filtering
2) Filter column A so it only shows blanks
3) Delete all lines shown
4) Clear the filter
0
 
kvrogersAuthor Commented:
I am designing this for a  end user who only wants to click a macro to do everything.  The table will be updated and ALL the rows where column A is blank will be deleted.
0
 
Ramesh VCommented:
Please use the following code:

Sub Check_Blank_And_Delete_Entire_Row()
Dim wb As Workbook
Dim ws As Worksheet
Dim lLastRow As Long
Set wb = ThisWorkbook
Set ws = wb.Sheets("Sheet1")
lLastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
    For i = 2 To lLastRow
        If Sheets(1).Range("A" & i).Value = "" Then
            Cells(i, 1).EntireRow.Delete
        End If
    Next i
End Sub
0
 
Ramesh VCommented:
Delete one by one or store the row numbers in a string and delete at the end.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now