XL: No Error Message with Incorrect Range Reference Syntax

Last reviewed: September 2, 1997
Article ID: Q151097
The information in this article applies to:
  • Microsoft Excel versions 5.0, 5.0a, 5.0c
  • Microsoft Excel for Windows 95, version 7.0
  • Microsoft Visual Basic Programming for Applications

SYMPTOMS

Although inserting an exclamation point before the left parenthesis of the Range method is incorrect syntax in Visual Basic for Applications, it may not produce an error message.

STATUS

Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

Microsoft provides examples of Visual Basic for Applications procedures for illustration only, without warranty either expressed or implied, including, but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. The Visual Basic procedures in this article are provided 'as is' and Microsoft does not guarantee that they can be used in all situations. While Microsoft support engineers can help explain the functionality of a particular macro, they will not modify these examples to provide added functionality, nor will they help you construct macros to meet your specific needs. If you have limited programming experience, you may want to consult one of the Microsoft Solution Providers. Solution Providers offer a wide range of fee-based services, including creating custom macros. For more information about Microsoft Solution Providers, call Microsoft Customer Information Service at (800) 426-9400.

You receive the error message, "Type-declaration character does not match declared data type," when setting a range variable with the syntax used in the following sample macro:

   Option Explicit
   Sub DisplaysError()
      Dim ws as Worksheet
      Dim r as Range
      Set ws = Sheets!Sheet1
      Set r = ws.range!("A1:A6")
   End Sub

The following syntax does not produce an error message:

   Option Explicit
   Sub DoesNotDisplayError()
      Dim r as Range
      Set r = Sheets!Sheet1.Range!("A1:A6")
   End Sub

Using the exclamation point after Range when setting the range variable off of a worksheet variable properly produces an error message. Using the exclamation point when the range variable is set off of a worksheet reference does not produce an error message.

REFERENCES

For more information about the range method in Microsoft Excel 5.0, search for "range method" and then "range method" using the Microsoft Excel Visual Basic Reference Help file.

For more information about the range method in Microsoft Excel 7.0, search for "range method" and then "range method" using the Microsoft Excel for Windows 95 Help Index.


Additional query words: 5.00 7.00
Keywords : PgmOthr kberrmsg kbprg
Version : 5.00 7.00
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.