Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3225668
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:21:58+00:00 2026-05-17T16:21:58+00:00

I have already a defined name for a particular column in my worksheet. How

  • 0

I have already a defined name for a particular column in my worksheet.
How to display a cell value by its defined name?

I’ve tried these:

  Public Sub Test()
    Dim R As Range
    Set R = ThisWorkbook.Names("SomeName").RefersToRange
    MsgBox CStr(R.Value)
  End Sub

but run-time error occured “Type Mismatch” (error code: 13).

What’s wrong with the code?
What is the actual data type of RefersToRange.Value?

The documentation says that RefersToRange returns the Range object, but it seems differ with the Range object returned by ActiveCell, because I’ve no problem with the following code:

  MsgBox CStr(ActiveCell.Value)

I’ve been using Excel 2003

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:21:59+00:00Added an answer on May 17, 2026 at 4:21 pm

    RefersToRange does return a Range object. I assume you’re getting your Type Mismatch on the Cstr line. If the range has multiple cells, the Value property returns a Variant array. Do this in the Immediate Window (Control+G in the VBE).

    ?typename(thisworkbook.Names("SomeRange").RefersTorange)
    Range
    ?typename(thisworkbook.Names("SomeRange").RefersToRange.Value)
    Variant()
    

    The CStr function can’t handle an array argument and that’s why you’re getting that error. You can get to a particular cell in the range, like the first cell, like this

    ThisWorkbook.Names("SomeRange").RefersToRange(1).Value
    

    Or loop through them as Fink suggests.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have defined a new dialog and its controls in an already existing resource
I have already tried PreRenderComplete and unload is too late
In .NET I have already tried the configuration below successfully: <system.net> <connectionManagement> <add address=*
I have already posted something similar here but I would like to ask the
I have already googled for this I have a Table with following structure in
The basics have already been answered here . But is there a pre-built PHP
I know I have already answered a similar question ( Running Batch File in
I have a repository which I have already cloned from Subversion. I've been doing
I believe several of us have already worked on a project where not only
OK, I know there have already been questions about getting started with TDD ..

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.