Names RefersToRange property - VBA RT error

Jon von der Heyden

MrExcel MVP, Moderator
Joined
Apr 6, 2004
Messages
10,907
Office Version
  1. 365
Platform
  1. Windows
I'm baffled...

Both customer and I are on Excel 32bit. I am on 64bit Win7, customer is on 32bit.

Taking an excerpt of the code:
Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim rngTarget As Excel.Range
    Dim rngCell As Excel.Range


    Set rngTarget = Target.Resize(1, 1)


    With Application
        .ScreenUpdating = False
        .Calculation = xlManual
        .EnableEvents = False
    End With


    With Me
        '-- View name change; populate the view description if the view already exists
        If rngTarget.Address = .Range(mstrREF_NAME).Address Then
            .Range(mstrREF_DESCRIPTION).Value = Replace$(CStr(Application.VLookup(.ViewName, ThisWorkbook.names(mstrREF_VIEWS).RefersToRange, 2, False)), _
                                                         "Error 2042", _
                                                         "")
        End If

Customer gets "Application or object defined error". No problems on my side.

mstrREF_NAME is a string that refers to worksheet scoped name. The name refers to a single cell.
mstrREF_DESCRIPTION is a string that refers to worksheet scoped name. The name refers to a single cell.
mstrREF_VIEWS is a string that refers to a workbook scoped name. This is a dynamic named range that refers to a 10R x 4C grid in a different worksheet

Any ideas people?
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
What is the ViewName property, Jon? I can't find it in Help or the Object Browser.
 
Upvote 0
Sorry I should have mentioned.

Code:
Public Property Get ViewName() As String
        ViewName = Me.Range(mstrREF_NAME).Value
End Property
 
Upvote 0
I would break the offending line into several lines and see which falls over on his system.
 
Upvote 0
I think you're right Steve. I have a call scheduled with him tomorrow. Was just wondering (hoping) that it was something obvious I had overlooked...

Thanks for looking. Sorry to baffle with that property!
 
Upvote 0
You're welcome, good luck.
 
Upvote 0
Turns out that on my customers machine it outright refuses to resolve RefersToRange for a dynamic range:

Code:
ThisWorkbook.names(mstrREF_VIEWS).RefersToRange

Application-defined or object-defined error. Strange because it is absolutely fine on my machine!
 
Upvote 0
How about using referstorange.address(external:=true)?
 
Upvote 0
That's exactly what I tried :) When he wakes up I'm going to ask him to test:

Rich (BB code):
Evaluate(ThisWorkbook.names(mstrREF_VIEWS).RefersTo)

I tend to avoid this method generally because it fails in an addin; but since this isn't an addin I'm hoping it will work.
 
Upvote 0
Still plodding on with this one.

The workbook is for users in the Nordic countries. I have used a dynamic range name in the workbook:
Rich (BB code):
=Views!$A$3:INDEX(Views!$D:$D,MATCH(BigText,Views!$A:$A,1),1)
What the user sees is:
Rich (BB code):
=Views!$A$3:INDEX(Views!$D:$D;MATCH(BigText;Views!$A:$A;1);1)

Ok so that bit is fine; the name returns a valid range.

It seems that in VBA RefersToRange will not resolve it. Is anyone aware of this? I know we have local version of RefersTo and RefersToR1C1 (although I've never fully understood it).

MSDN Developers Reference doesn't make any suggestion of international issues with RefersToRange (as far as I can see)...
 
Upvote 0

Forum statistics

Threads
1,214,797
Messages
6,121,629
Members
449,041
Latest member
Postman24

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