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.
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.