Automatic Row Height for Wrapped Text

SaraWitch

Active Member
Joined
Sep 29, 2015
Messages
322
Office Version
  1. 365
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

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
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
What is the default minimum?
 
Upvote 0
Is there any particular column you want to look at?
 
Upvote 0
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
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
In what way doesn't it work?
 
Upvote 0
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,214,641
Messages
6,120,691
Members
448,978
Latest member
rrauni

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
Back
Top