1004 - Method 'Range' of object '_Worksheet' failed...

Aid2Kids

New Member
Joined
Oct 27, 2017
Messages
9
Greetings!

Excel 2010 (14.0.7190.5000) 64-bit
Win 8.1 Pro

I'm getting a 1004 error, "Method 'Range' of object '_Worksheet' failed", when I try to access a WORKBOOK-scope defined-name from a sheet's Worksheet_Activate() routine. Here's the code for the sheet...

Code:
Private Sub Worksheet_Activate()
     MsgBox "DefName contents = " & Range("TestDefName").Value
End Sub

This very code runs just fine from a code module, but not from the worksheet routine. Would someone be so kind as to give me a clue?


THANKS!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
In a worksheet code module, Range defaults to the sheet containing the code. I'm guessing that sheet does not contain your named range, so use:

Code:
Private Sub Worksheet_Activate()
     MsgBox "DefName contents = " & Application.Range("TestDefName").Value
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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