determining whether all cells in a row are blank

  • Thread starter Thread starter rub
  • Start date Start date
R

rub

I want to delete rows that have nothing in the cells. How do I
determine whether all cells in a row are blank? Any help would be
greatly appreciated.
 
Hi Rub
Use this function

Public Function IsBlankRow(ByRef ws As Worksheet, ByVal lRow&) As Boolean
Dim c As Range
With ws
For Each c In .Rows(lRow).Cells
If c.Value <> "" Then
IsBlankRow = False
Exit Function
End If
Next c
End With
IsBlankRow = True
End Function

You can call it as shown below
Isblankrow(worksheets("Sheet1"),5)
or
IsBlankRow(Sheet1,5)

the second version uses the programmatic name of the sheet and hence does
not need to be enclosed in double quotes.
 
Thanks. I will try it.

Hi Rub
Use this function

Public Function IsBlankRow(ByRef ws As Worksheet, ByVal lRow&) As Boolean
Dim c As Range
With ws
For Each c In .Rows(lRow).Cells
If c.Value <> "" Then
IsBlankRow = False
Exit Function
End If
Next c
End With
IsBlankRow = True
End Function

You can call it as shown below
Isblankrow(worksheets("Sheet1"),5)
or
IsBlankRow(Sheet1,5)

the second version uses the programmatic name of the sheet and hence does
not need to be enclosed in double quotes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top