VBA versus XLM

Before version 5, Excel used a powerful (but very cryptic) macro language called XLM. Later versions of Excel still execute XLM macros, but the ability to record macros in XLM was removed beginning with Excel 97. As a developer, you should be aware of XLM (in case you ever encounter macros written in that system), but you should use VBA for your development work.

Don't confuse the XLM macro language with eXtensible Markup Language (XML). Although these terms share the same letters, they have nothing in common. XML is a storage format for structured data. Excel 2003 contains some new XML-related features.

Figures 7-1 and 7-2 show a simple procedure coded in both XLM and VBA. This macro works on the selected cells. It changes the cell background color and adds a border around the cells. You probably agree that the VBA code is much easier to read. More importantly, however, the VBA code is also easier to modify when the need arises.

Figure 7-1: A simple macro coded in Excel's XLM language, stored on a macro sheet.

vs vba.xls - Modulel (Code)

^^M-hlxl

|(General)

Miicio2

Uith Selection

. BorderAround Weight: =xlHediui[i/ Colorlndex: =xlAutoitiatic .Interior.Colorlndex = 6 .Interior.Pattern = xlSolid End Uith End Sub

SulD Ilacro2 ()

Uith Selection

. BorderAround Weight: =xlHediui[i/ Colorlndex: =xlAutoitiatic .Interior.Colorlndex = 6 .Interior.Pattern = xlSolid End Uith End Sub

Figure 7-2: A simple macro coded in Excel's VBA language, stored in a VBA module.

Was this article helpful?

0 -1

Post a comment