Microsoft KB Archive/79191

{| = Excel: Keeping Formats when Changing Numbers to Text in Macro =
 * width="100%"|

Last reviewed: November 3, 1994

Article ID: Q79191 The information in this article applies to:
 * Microsoft Excel for Windows, versions 2.1 and 3.0
 * Microsoft Excel for OS/2, versions 2.2 and 3.0

SUMMARY
Numbers in a worksheet or macro sheet can be converted to text while automatically maintaining the existing number format by using the command macro described below.

MORE INFORMATION
The macro statement shown below will replace the number in the active cell with its text equivalent, while retaining the original number format.

=FORMULA(CHAR(61)&CHAR(34)&TEXT(ACTIVE.CELL, IF(GET.CELL(7)=&quot;General&quot;,&quot;#&quot;,GET.CELL(7)))&CHAR(34)) Normally, using the TEXT function within the FORMULA function will cause the text to be converted to a number when placed into a worksheet cell. The above formula first gets the number format, applies the format to the text, and then concatenates an equal sign (&quot;CHAR(61)&quot;) and double quotation marks (&quot;CHAR(34)&quot;) to the beginning and the end to ensure that the text remains as text. As a result, you do not have to specify a format; the existing number format is applied automatically.