LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiply an entire spreadsheet by 1000 without going into ea cell Jacham Excel Worksheet Functions 4 April 9th 23 12:46 PM
Macro to highlight an entire row if a certain value is in a cell Maggie Excel Discussion (Misc queries) 1 January 28th 09 07:29 PM
Edit macro to match entire cell contents nis75p06 Excel Discussion (Misc queries) 1 September 3rd 05 04:27 PM
How to change numbers in entire spreadsheet from one cell? Lady Lioness Excel Worksheet Functions 2 August 5th 05 04:50 PM
Macro for selecting entire row from mouse cell selection PaiolaS Excel Programming 1 August 7th 03 07:01 PM


All times are GMT +1. The time now is 01:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"