Automatic Row Height for Wrapped Text

SaraWitch

Board Regular
Joined
Sep 29, 2015
Messages
153
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Hello peeps,

I would like to automatically adjust the row height for wrapped text (i.e., not do this manually). I also don't want to use the AutoFit Row Height because I want a default minimum height. I did find the following formula online which I have tried in the worksheet, ThisWorkbook, and a Module, but it's not working for me:

Sub AutofitRows()
For Each CL In UsedRange
If CL.WrapText Then CL.Rows.AutoFit
Next
End Sub

Any tips?

Ta muchly, folks! :)
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

GWteB

Well-known Member
Joined
Sep 10, 2010
Messages
2,828
Office Version
  1. 2013
Platform
  1. Windows
How about ...
VBA Code:
Sub Wrap40()
    Dim c As Range
    For Each c In ActiveSheet.UsedRange
        If c.WrapText Then c.RowHeight = 40
    Next
End Sub
 
Upvote 0

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
83,233
Office Version
  1. 365
Platform
  1. Windows
What is the default minimum?
 
Upvote 0

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
83,233
Office Version
  1. 365
Platform
  1. Windows
Is there any particular column you want to look at?
 
Upvote 0

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
83,233
Office Version
  1. 365
Platform
  1. Windows
Thanks for that, however I realised the columns were irrelevant.
Try
VBA Code:
Sub SaraWitch()
   Dim Cl As Range
   
   With ActiveSheet.UsedRange
      .EntireRow.AutoFit
      For Each Cl In .Columns(1).Rows
         If Cl.RowHeight < 30.75 Then Cl.RowHeight = 30.75
      Next Cl
   End With
End Sub
 
Upvote 0

SaraWitch

Board Regular
Joined
Sep 29, 2015
Messages
153
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Hmmm. Still not working for me! I presume it is Cl (L) in formula, not C1 (one), but have tried both, and also presume formula is put in a Module, but I did also try it in ThisWorkbook and the sheet; with no luck.
:unsure:
 
Upvote 0

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
83,233
Office Version
  1. 365
Platform
  1. Windows
In what way doesn't it work?
 
Upvote 0

SaraWitch

Board Regular
Joined
Sep 29, 2015
Messages
153
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
Doh! Sorry @Fluff, I didn't run it!!! :oops: Works a treat; thank you! Don't suppose there's any way of only applying it from Row 7? ;)
 
Upvote 0

Forum statistics

Threads
1,191,273
Messages
5,985,691
Members
439,974
Latest member
sjoerdbosch

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top