Auto adjust row height to max height value

verynewtovba

New Member
Joined
Oct 7, 2016
Messages
5
Hello,

I have a spreadsheet used as a tracker where column A is Priority, column B is Item, column C is Description and column D is Comments.
Where most of the data entered is in the cells of column D then as the data in the cell grows, then what data is actually visible in the row currently needs to be manually adjusted by row height.
So, I was wondering if vba could be used to auto adjust the row height to a maximum value of 150px depending on any of the cell contents in the rows, so, if the row height is <150 then retain that row height up to a max of 150, I hope this makes sense, it's kinda asking if there's a way for row height to auto adjust up to a max of 150.

This is on Excel2010.

Here's what I've tried however doesn't work;

Sub MaxRowHeight()
Dim R As Long

R = Sheets("InProgress").Cells(Rows.Count, "A").End(xlUp).Row
If Rows(R).Height > 150 Then Rows(R).RowHeight = 150
Next
End Sub

Also tried this:

Sub MaxRowHeight()
Dim R As Long


For R = 1 To ActiveSheet.UsedRange.Rows.Count
If Rows(R).Height > 150 Then Rows(R).RowHeight = 150
Next
End Sub

Comments very much appreciated.
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
in you first marco, you use next without for.
the second marco should work. can you explain what is the error message?
 
Upvote 0
It was user error, had a type in my workbook, corrected and set to run on workbook open, thank you for responding.
 
Upvote 0

Forum statistics

Threads
1,215,743
Messages
6,126,615
Members
449,322
Latest member
Ricardo Souza

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