Microsoft KB Archive/151097

= No Error Message with Incorrect Range Reference Syntax =

Article ID: 151097

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 95 Standard Edition
 * Microsoft Excel 5.0c

-



This article was previously published under Q151097





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.

