Microsoft provides programming examples 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. This article assumes
that you are familiar with the programming language being demonstrated and the
tools used to create and debug procedures. Microsoft support professionals can
help explain the functionality of a particular procedure, but they will not
modify these examples to provide added functionality or construct procedures to
meet your specific needs. If you have limited programming experience, you may
want to contact a Microsoft Certified Partner or the Microsoft fee-based
consulting line at (800) 936-5200. For more information about Microsoft Certified
Partners, please visit the following Microsoft Web site:
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
To see an example of the problem, follow these steps:
- Start Microsoft Excel 5.0.
- Type the following into a new workbook:
A1: Left
A2: General
- Select cell A1, and then click Cells on the Format menu.
- Click the Alignment tab in the Format Cells dialog box. Under Horizontal, click Left, and then click OK.
- On the File menu, click Save As. In the File name box, type test. In the Save file as type list, click WK3 (1-2-3), and then click OK. Click OK again when the Summary Info dialog box appears.
- On the File menu, click Close. Click No when you are prompted to save the file in the Microsoft Excel format. On the File menu, click Test.WK3.
- On the Insert menu, point to Macro, and then click Module.
- Type the following Visual Basic subroutine in the new module sheet:
Sub Test()
Msgbox(Worksheets(1).Range("A1").Horizontalalignment = xlLeft)
Msgbox(Worksheets(1).Range("A2").Horizontalalignment = xlLeft)
End Sub
- Move the insertion point inside the subroutine. On the Run menu, click Start.
Both message boxes return True, even though cell A2 uses the General format.
- Close the Test.wk3 workbook and do not save the changes.
- Open the Test.wk3 workbook in Excel 2000.
- Select A1, and then click Cells on the Format menu.
- Click the Alignment tab in the Format Cells dialog box. Under Horizontal, click Left (Indent), and then click OK.
- Press ALT+F11 to start the Visual Basic editor, click Module on the Insert menu, and then type the following on the module sheet:
Sub Test()
Msgbox(Worksheets(1).Range("A1").Horizontalalignment = xlLeft)
Msgbox(Worksheets(1).Range("A2").Horizontalalignment = xlLeft)
End Sub
- Press ALT+F11 to return to Excel, press ALT+F8 to open the Macro dialog box, click Test, and then click Run.
In Microsoft Excel 2000, the first message box returns
True; the
second message box returns
False.