ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Displaying Cell Formulas (https://www.excelbanter.com/excel-discussion-misc-queries/109100-displaying-cell-formulas.html)

Stranded

Displaying Cell Formulas
 

--
Richard

ChristopherTri

Displaying Cell Formulas
 
I am assuming you want the formulas in you cells displayed without having to
double-click on them.

The following macro will copy the contents of the active sheet and paste
them as text on a new sheet:

Sub Formulas_to_text()
'
' Formulas_to_text Macro
' Macro written 9/9/2006 by ChristopherTri
'
' Macro copies the contents of the active sheet and pasts them onto a
' new sheet as text.
'

Dim test_formula() As Variant
new_column_width = 20 'Set width of
columns on new sheet

lastRow = ActiveSheet.UsedRange.Rows.Count 'find the last row
of the worksheet
lastColumn = ActiveSheet.UsedRange.Columns.Count 'find the last
column of the worksheet

ReDim test_formula(lastRow, lastColumn) As Variant 'Dimension array to
fit used range
'
' Copy formulas into array
'
For test_row = 1 To lastRow
For test_column = 1 To lastColumn
test_formula(test_row, test_column) =
ActiveSheet.Cells(test_row, test_column).Formula
Next test_column
Next test_row

Sheets.Add 'Add a new sheet
'
' Paste contents of array into new sheet as text
'
For test_row = 1 To lastRow
For test_column = 1 To lastColumn
ActiveSheet.Cells(test_row, test_column) = "'" &
test_formula(test_row, test_column)
Next test_column
Next test_row
'
' Format new sheet for better formula viewing
'
ActiveSheet.UsedRange.Select
With Selection
.ColumnWidth = new_column_width
.WrapText = True
End With

End Sub


After running the macro, you can either print or view as needed.




"Stranded" wrote:


--
Richard


Ryan Hartnett

Displaying Cell Formulas
 
Go Tools / Options
Select the View tab
Under Windows options, select the Formulas checkbox

You may quickly change your mind about showing formulas, but this will do
the trick.

Ryan


"Stranded" wrote:


--
Richard



All times are GMT +1. The time now is 02:48 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com