Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
leaftye
 
Posts: n/a
Default Autofit makes rows too tall


leaftye Wrote:
When I have multiple lines in a cell, Autofit makes my rows too tall no
matter how I activate the Autofit utility. What can I do so Autofit
sizes my rows properly?

Eugene


Here's what seems to be working for me:


Code:
--------------------

Sub TrimRightSpaces()
'David McRitchie 2000-07-03 mod 2000-08-16 join.htm
'Modified to only trim right spaces
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim cell As Range
'Also Treat CHR 0160, as a space (CHR 032)
Selection.Replace What:=Chr(160), Replacement:=Chr(32), _
LookAt:=xlPart, SearchOrder:=xlByRows, MatchCase:=False
'Trim in Excel removes extra internal spaces, VBA does not
On Error Resume Next 'in case no text cells in selection
For Each cell In Intersect(Selection, _
Selection.SpecialCells(xlConstants, xlTextValues))
cell.Value = Application.RTrim(cell.Value)
Next cell
On Error GoTo 0
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
End Sub

Sub RowHeight()
Dim OriginalWidth As Integer
Dim OriginalHeight As Integer
Dim NewHeight As Integer

Application.ScreenUpdating = False

'Eliminate white space so this function can work properly
TrimRightSpaces

'Excel likes it when you change width back and forth
'before setting the height....
With ActiveCell
OriginalWidth = .ColumnWidth
OriginalHeight = .RowHeight
.EntireColumn.AutoFit
.ColumnWidth = 47
With .EntireRow
.AutoFit
NewHeight = .RowHeight
End With
.RowHeight = NewHeight '+ 15
.ColumnWidth = OriginalWidth
End With

Application.ScreenUpdating = True
End Sub

--------------------


--
leaftye
Reply
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
Insert rows based on specific value bob Excel Worksheet Functions 6 February 29th 08 07:11 PM
Autofit makes rows too tall leaftye Excel Discussion (Misc queries) 0 July 5th 05 05:16 PM
Hiding Rows if the linked rows are blank KG Excel Discussion (Misc queries) 9 May 18th 05 02:32 AM
Row selections by row # OR by even/odd rows in another spreadsheet Tom Excel Discussion (Misc queries) 0 February 9th 05 04:03 PM
Adding Rows to Master Sheet Excel Newbie New Users to Excel 1 December 23rd 04 10:56 PM


All times are GMT +1. The time now is 09:28 PM.

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"