Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Macro in 1 cell vs entire spreadsheet
Hi guys,
I have a macro (see Below) that works when you run it, BUT ONLY runs on the currently selected cell. I need it to run over the entire spreadsheet (or preferably over a range that I specify, say A5:s100 - there are several sheets and ranges though...) Please can someone help.... Kind Regards Darin Sub AutoFitMergedCellRowHeight() Dim CurrentRowHeight As Single, MergedCellRgWidth As Single Dim CurrCell As Range Dim ActiveCellWidth As Single, PossNewRowHeight As Single If ActiveCell.MergeCells Then With ActiveCell.MergeArea If .Rows.Count = 1 And .WrapText = True Then Application.ScreenUpdating = False CurrentRowHeight = .RowHeight ActiveCellWidth = ActiveCell.ColumnWidth For Each CurrCell In Selection MergedCellRgWidth = CurrCell.ColumnWidth + _ MergedCellRgWidth Next .MergeCells = False .Cells(1).ColumnWidth = MergedCellRgWidth .EntireRow.AutoFit PossNewRowHeight = .RowHeight .Cells(1).ColumnWidth = ActiveCellWidth .MergeCells = True .RowHeight = IIf(CurrentRowHeight PossNewRowHeight, _ CurrentRowHeight, PossNewRowHeight) End If End With End If *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Multiply an entire spreadsheet by 1000 without going into ea cell | Excel Worksheet Functions | |||
Macro to highlight an entire row if a certain value is in a cell | Excel Discussion (Misc queries) | |||
Edit macro to match entire cell contents | Excel Discussion (Misc queries) | |||
How to change numbers in entire spreadsheet from one cell? | Excel Worksheet Functions | |||
Macro for selecting entire row from mouse cell selection | Excel Programming |