Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-11-2011, 03:06 AM
Snvlsfoal Snvlsfoal is offline Row height question Windows XP Row height question Office 2004 for Mac
Banned
Row height question
 
Join Date: Jul 2011
Posts: 9
Snvlsfoal is on a distinguished road
Default Row height question

How can I set row height to two lines of text as a minimum, or more if cell contents requires it?

The row height should vary according to the font size. The entire worksheet will be in the same font size. Selecting the entire worksheet and increasing/decreasing font size should change the row height accordingly.

If a row contains nothing at all, then the row height should still be two lines. If a row contains a cell with a long entry that will wrap over more than two lines, then the row height should automatically expand to accommodate the text (to three lines or more).

I thought it was an easy one but so far I haven't been able to figure it out for myself or by searching this forum. Can anyone please help?
Reply With Quote
  #2  
Old 08-11-2011, 05:30 AM
Catalin.B Catalin.B is offline Row height question Windows Vista Row height question Office 2007
Expert
 
Join Date: May 2011
Location: Iaşi, Romānia
Posts: 386
Catalin.B is on a distinguished road
Default

you can try this macro...(there could be better solutions) ;adjust elements in red to fit:
Sub getFontsize()
Dim i As Integer
Application.ScreenUpdating = False
For i = 1 To 15
Rows(i).Select
Selection.RowHeight = 2 * (ActiveSheet.Cells(i, 1).Font.Size + 5)
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
If Len(ActiveSheet.Cells(i, 1)) > 30 Then
.Rows.AutoFit
End If
End With

Next i
Application.ScreenUpdating = True
End Sub

Attention: if you use merged cells, or if your cells containing formulas, it will not work properly
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro or user function to Extract row height Catalin.B Excel 12 06-22-2011 09:21 AM
Pasting HTML into Excel (height auto-adjust) c-tran Excel 0 03-11-2010 07:30 AM
Row height question One to many and many to one question Girlie4 Excel 3 08-09-2009 08:02 PM
Validate the height of the text when you save (VBA) jhpe Word VBA 0 08-22-2008 06:59 PM
Categories question & replying with attachment question glitzymama Outlook 0 03-15-2006 09:32 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:46 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft