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 Microsoft Advisory Services. For more information, visit these Microsoft Web sites:
Microsoft Certified
Partners -
https://partner.microsoft.com/global/30000104Microsoft Advisory Services -
http://support.microsoft.com/gp/advisoryservice
For more information about the support options that are available and about how to contact Microsoft, visit the following Microsoft Web site:
http://support.microsoft.com/default.aspx?scid=fh;EN-US;CNTACTMS
In Microsoft Excel, you cannot view the formulas in a worksheet in one
area of the worksheet and the results of the formulas in another area.
Instead, you must edit the formulas so that they appear in text format. To
do so, insert an apostrophe in front of the equal sign (=) of the formula.
An efficient way to do this is to use a Visual Basic for Applications
macro.
Note that cells in which apostrophes are the first character are not
affected by this procedure.
The following procedure adds an apostrophe in front of text, values, or
formulas in the current selection:
'Appends hidden apostrophe as first character.
'Works on cells with formulas, text, or values.
'Excellent for displaying formulas when printing.
Sub ApostroPut()
For Each currentcell In Selection
'Prevents inserting apostrophes in blank cells.
If currentcell.Formula <> "" Then
currentcell.Formula = "'" & currentcell.Formula
End If
Next
End Sub
The following procedure removes the apostrophe in front of text,
values, or formulas in the current selection:
'Removes hidden apostrophes that are first characters.
'Works on cells with formulas, text, or values.
Sub ApostroRemove()
For Each currentcell In Selection
If currentcell.HasFormula = False Then
'Verifies that procedure does not change the
'cell with the active formula so that it contains
'only the value.
currentcell.Formula = currentcell.Value
End If
Next
End Sub
NOTE: You can restore a value that you changed to text by copying the number 1, selecting the cells that contain the text that you want to restore, and using the
Paste Special command on the
Edit menu with the multiplication operation.