What I'm trying to do is pretty simple. I made it even simpler in trying to figure out what's going on. And it seems that the VBA code I'm writing works fine when a named range has a single cell, but not when it has multiple cells. And I don't know why.
(As background, I've been programming for almost 45 years, but have only meager experience with VBA.)
The Define Name dialog box shows
and my VBA function is
I put =whatever() in some cell. The MsgBox displays the two names as expected. The MsgBox to display the value in [mycell] works as expected. Then the next MsgBox never comes up and the cell shows #VALUE!.
(The final code is intended to have something other than 0,0 for the offset.)
Can anyone give me a clue?
Edward
(As background, I've been programming for almost 45 years, but have only meager experience with VBA.)
The Define Name dialog box shows
Code:
mycell =Sheet1!$C$8
mycells =Sheet1!$E$7:$E$9
Code:
Option Explicit
Function whatever()
Dim rnum As Integer
Dim nm
For Each nm In Names
MsgBox nm.Name + " " + nm.RefersTo
Next nm
rnum = [mycell].Offset(0, 0).Value
MsgBox rnum
rnum = [mycells].Offset(0, 0).Value
MsgBox rnum
End Function
(The final code is intended to have something other than 0,0 for the offset.)
Can anyone give me a clue?
Edward