Method 'range' of object '_worksheet failed error on a simple formula and code

Skysurfer

Board Regular
Joined
Apr 19, 2004
Messages
202
Office Version
  1. 2019
Platform
  1. Windows
  2. MacOS
Hi,

In a module, I have the following:

Code:
IF Sheet4.Range("TheList_CountBlanks").Value > 0 Then
Msgbox "Helpful message."
Exit Sub
End If

That range name uses the function COUNTBLANK on a simple range and is successfully used in formulas. But that code keeps blowing up with that error.

What am I doing wrong?

Lawrence
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try this, The following is to obtain the result of the formula.

Code:
  If [TheList_CountBlanks] > 0 Then
    MsgBox "Helpful message."
    Exit Sub
  End If
 
Upvote 0
Thanks for the quick reply.

I tried your code and got the error message "Compile error: Can't find project or library."

Lawrence
 
Upvote 0
How did you create the name range and what do you have inside it?
 
Upvote 0
Really appreciate your help.

In the Name Manager, I created a named range entitled "TheList_CountBlanks" with the range "=COUNTBLANK(Intake_Form!$B$49:$B$63)". The function result = 1.

Lawrence
 
Upvote 0
In scoope did you put workbook?
Try:

Code:
If Evaluate("=TheList_CountBlanks") > 0


Another doubt:

Excel version?
 
Upvote 0
That worked!

Thank you.

But why do you think my OP and your 1st try didn't work? Did Evaluate force a special solution?

The range name scope is Workbook and I'm using Excel 365 ProPlus.

Lawrence
 
Upvote 0
That worked!

Thank you.

But why do you think my OP

It does not evaluate a formula, it shows the value of the cell.


and your 1st try didn't work?

For your excel version, I have 2007.
Hi
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

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