Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Need Formula Listing Code Modification
This code creates a new worksheet in a workbook and lists all formulas contained in the target worksheet. Could someone help modify this code to do the following:
1. The resulting list contains many rows where there are no formulas would like to omit the blank (no formula) rows. 2. Make the column width for column B and C be 45 (rather than the existing auto fit). 3. When the data in column B or C exceeds the 45 width, expand row height to fit the text, and wrap text. 4. When the formula in column B references a workbook other than the current workbook, make font red in all cells in that row. Any help would be much appreciated. Thanks, Phil Sub ListFormulas() Dim FormulaCells As Range, Cell As Range Dim FormulaSheet As Worksheet Dim Row As Integer 'Create a range object for all formula cells On Error Resume Next Set FormulaCells = Range("A1").SpecialCells(xlFormulas, 23) 'Exit if no formulas found If FormulaCells Is Nothing Then MsgBox "No Formulas, or the sheet is protected." Exit Sub End If 'Add a new worksheet Application.ScreenUpdating = False Set FormulaSheet = ActiveWorkbook.Worksheets.Add FormulaSheet.Name = "Formulas in " & FormulaCells.Parent.Name 'Set up the column headings With FormulaSheet Range("A1") = "Address" Range("B1") = "Formula" Range("C1") = "Value" Range("A1:C1").Font.Bold = True End With 'Process each formula Row = 2 For Each Cell In FormulaCells Application.StatusBar = Format((Row - 1) / FormulaCells.Count, "0%") With FormulaSheet Cells(Row, 1) = Cell.Address(RowAbsolute:=False, ColumnAbsolute:=False) Cells(Row, 2) = " " & Cell.Formula Cells(Row, 3) = Cell.Value Row = Row + 1 End With Next Cell 'Adjust column widths FormulaSheet.Columns("A:C").AutoFit Application.StatusBar = False End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
modification to this code | Excel Discussion (Misc queries) | |||
Code modification help | Excel Worksheet Functions | |||
Code Modification | Excel Programming | |||
Help in Modification of existing code | Excel Programming | |||
Modification to code | Excel Programming |