Home » excel » Excel worksheet references in general and in hyperlink function

Excel worksheet references in general and in hyperlink function

Posted by: admin May 14, 2020 Leave a comment

Questions:

What is the correct syntax for references to worksheets in the same and different workbooks?

I have found a good and detailed answer to this question at AbleBits. However, the syntax given there does not work in the hyperlink function. Microsoft’s documentation of the function gives numerous examples of such references, but does not include two very important case: a different worksheet in the same workbook, and a worksheet whose name includes a space.

I have figured out by trial and error what appears to be the correct syntax and am posting this question for the purpose of providing the answer.

How to&Answers:

References for use in general, except in hyperlink function:

  • Reference to range in another worksheet in the same workbook:

    '<sheet name>'!<range>

  • Reference to range in an open workbook:

    '[<filename>]<sheet name>'!<range>

  • Reference to range in any workbook, open or closed:

    '<path>[<filename>]<sheet name>'!<range>

This last one does not work in the indirect function if the file is closed. indirect simply does not work on closed files. I have not found any way to directly reference data in a closed workbook.

The single quote ' is necessary for sheet names that have a space in them and is included here for the general syntax that works with all sheet names.

The brackets [] shown here are actual brackets, not symbols signifying syntax elements that are optional, as such brackets are often used in syntax formulas.

Source: How to create external reference in Excel to refer to another sheet or workbook, AbleBits.com, 2015 12 08

References in hyperlink function:

  • Reference to range in another worksheet in the same workbook:

    #'<sheet name>'!<range>

  • Reference to range in an open workbook:

    [<filename>]'<sheet name>'!<range>

  • Reference to range in any workbook, open or closed:

    [<path><filename>]'<sheet name>'!<range>

Source: HYPERLINK function, Microsoft, except that does not say anything about the use of # or ', which I had to figure out by trial and error.

Differences between references in general and in hyperlink:

  • In hyperlink, a reference to a range in another worksheet in the same workbook is prefaced with #.
  • When specifying the workbook, in general, the single quotes ' enclose everything before the exclamation point !, but in hyperlink, they only enclose the sheet name.
  • When specifying the workbook, in general, the brackets [] enclose only the filename, but in hyperlink, they also enclose the optional path.

I’d like to know if anyone sees anything wrong with the syntax stated here. I’d also like to know if anyone has a reference for the correct syntax for the the references in hyperlink, and any official Microsoft documentation for the references in general instead of the AbleBits reference given.