XL: No Error Message with Incorrect Range Reference Syntax

ID: Q151097


The information in this article applies to:
  • Microsoft Excel for Windows, versions 5.0, 5.0a, 5.0c
  • Microsoft Excel for Windows 95, version 7.0
  • Microsoft Visual Basic, Application Edition, version 1.0


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 professionals 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
   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

Keywords :
Version : WINDOWS:5.0,5.0a,5.0c,7.0; :1.0
Platform : WINDOWS
Issue type :


Last Reviewed: October 18, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.