Checking for empty cells

UHsoccer

Well-known Member
Joined
Apr 3, 2002
Messages
1,023
I want use the following code to test if a specific range is empty


If Not IsEmpty(Range("G11:H11")) Then - displays NOT empty

BUT

If Not IsEmpty(Range("G11:G11")) Then - displays empty
If Not IsEmpty(Range("H11:H11")) Then - displays empty

What is the syntax error in the first one
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
This is because range is returning (by default) the value property - for a single cell this is the value, however for a range its going to be an array of values - which by definition isnt empty (though the individual elements may be)

so perhaps:

Application.WorksheetFunction.CountA(Range("A1:a5"))
 
Upvote 0
So I should do one cell at the time, or is there another property that I can query on to handle the range (which in reality is from column F to R)
 
Upvote 0
used your (macleanb) code and for ONE cell is still thinks there is data

If Not IsEmpty(Application.WorksheetFunction.CountA(Range("G11:G11")))

with

If Not IsEmpty(Range("G11:G11")) it is empty
 
Upvote 0
What I meant was:


if Application.WorksheetFunction.CountA(Range("A1:a5")) > 0 then


....


endif
 
Upvote 0

Forum statistics

Threads
1,203,674
Messages
6,056,679
Members
444,881
Latest member
Stu2407

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