Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

XL2000: Number Signs (#) Appear in Recorded Macros


View products that this article applies to.

This article was previously published under Q211848

↑ Back to the top


Symptoms

When you record a Microsoft Visual Basic for Applications macro in Microsoft Excel 2000, numbers in the recorded code may be followed by number signs (#), as in the following example:
ActiveSheet.Shapes.AddShape(msoShapeRectangle, 27.75, 6#, _ 223#, 118#).Select
				

↑ Back to the top


Cause

This behavior occurs if the values are the Double type, in which case, Excel adds number signs to values when you record a macro. Excel adds number signs only to values that are whole numbers followed by ".0" (for example, 6.0, 118.0, and so on). This behavior does not occur when values are not whole numbers (for example, 27.75 or 15.5).

↑ Back to the top


Resolution

The number signs in the recorded macro do not cause any problems, and it is not necessary to remove them. However, you can remove the number signs without affecting the functionality of the macro.

↑ Back to the top


More information

In Visual Basic for Applications, number signs are used to indicate that the number to which they are attached is the Double type; for example:
115#
When you record a Visual Basic for Applications macro, Excel may automatically set recorded numbers that are whole numbers to the Double type by adding a number sign after each number. This behavior does not affect the functionality of the macro in any way.

You can also observe this behavior by typing the following subroutine into a new Visual Basic module:
Sub Test()
    Dim X As Integer
   X = 3.0 + 5.0
End Sub
				
When you type the third line of code, the values in the line are converted into the Double type:
X = 3# + 5#
				
This is an automatic feature in Visual Basic for Applications. If you type the following line of code instead
X = 3 + 5
				
the values are not converted into the Double type because the values do not end in ".0."

↑ Back to the top


Keywords: KB211848, kbprogramming, kbprb, kbnofix, kbcode

↑ Back to the top

Article Info
Article ID : 211848
Revision : 6
Created on : 10/11/2006
Published on : 10/11/2006
Exists online : False
Views : 241