Check if all cells in range are empty?

Cymae

Board Regular
Joined
Oct 19, 2008
Messages
70
I have an if statement as follows:

Code:
If IsEmpty(Range(Cells(iCurrentRow, iFirstDataColumn), Cells(iCurrentRow, iTotalCol))) Then

i did a select to make sure it was selecting the whole range I want and it works fine:

Code:
Range(Cells(iCurrentRow, iFirstDataColumn), Cells(iCurrentRow, iTotalCol)).Select

Inside my range I can have cells with 0s in them and cells with nothing in them. What I would like my if statement to do is return true ONLY when ALL cells have nothing in them. At the moment, even if I have 0's in some cells, it's returning false.

Am I doing something wrong?
 
So, we are back to doing a sum function on a range within a row. If the range I am looking at is empty or any cell in the range is not a number, I want to skip it. The empty part works fine, now I just have to get it to ignore ranges that include non-numeric cells.
 
Upvote 0

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi Cymae:

You may want to try ...
Code:
If myRange.Cells.Count = Evaluate("=sumproduct((isblank(" & myRange.Address & ")+0))") Then
    MsgBox "all cells are empty"
    Else
    MsgBox "not all cells are empty"
End If

Let me know if this works for you.
 
Upvote 0
Hi Cymae:

You may want to try ...
Code:
If myRange.Cells.Count = Evaluate("=sumproduct((isblank(" & myRange.Address & ")+0))") Then
    MsgBox "all cells are empty"
    Else
    MsgBox "not all cells are empty"
End If

Let me know if this works for you.

I have the empty part working now thanks to jindon's excellent advice, I am trying to get the numeric part going :)
 
Upvote 0
So, we are back to doing a sum function on a range within a row. If the range I am looking at is empty or any cell in the range is not a number, I want to skip it. The empty part works fine, now I just have to get it to ignore ranges that include non-numeric cells.
And how hidden cells are concerned ?
 
Upvote 0
So, we are back to doing a sum function on a range within a row. If the range I am looking at is empty or any cell in the range is not a number
Then simplh use Count function

Application.Count(Range) <> Range.Cells.Count Then
blank or cells other than numeric value exists
 
Upvote 0
Then simplh use Count function

Application.Count(Range) <> Range.Cells.Count Then
blank or cells other than numeric value exists

Much Obliged. But will this return true even If I have some blank cells?

Because SOME Blank cells are OK, I just don't want non-numeric cells or ALL blank cells....
 
Upvote 0
Much Obliged. But will this return true even If I have some blank cells?

Because SOME Blank cells are OK, I just don't want non-numeric cells or ALL blank cells....
Confusing...
Code:
If (Application.CountBlank(Range) <> Range.Cells.Count) * _
   (Application.CountA(Range) = Application.Count(Range)) Then
        'Process
End If
 
Upvote 0
Using isNull(Range) will tell you if any cell in the range has a value, otherwise the Range.text property will return "" if all cells are blank.
 
Upvote 0

Forum statistics

Threads
1,214,382
Messages
6,119,194
Members
448,874
Latest member
Lancelots

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top