![]() |
Format RowHeight question
Hi,
I have text in a column of rows that is 9 point Lucida Console. Some of the cells in the column contain several rows of text. I want to format the row height something like ; For i = 1 To 1000 If Range("B" & i) = Four Rows Of Text Then RowHeight = 95 If Range("B" & i) = Three Rows Of Text Then RowHeight = 85 End If End If Next i Any help is very much appreciated. |
Format RowHeight question
Why not use
Range("B" & i).Rows.AutoFit -- HTH, Barb Reinhardt "ChipButtyMan" wrote: Hi, I have text in a column of rows that is 9 point Lucida Console. Some of the cells in the column contain several rows of text. I want to format the row height something like ; For i = 1 To 1000 If Range("B" & i) = Four Rows Of Text Then RowHeight = 95 If Range("B" & i) = Three Rows Of Text Then RowHeight = 85 End If End If Next i Any help is very much appreciated. |
Format RowHeight question
Give this code a try...
Sub SetRowHeight() Dim i As Long Dim CellVal As String For i = 1 To 1000 CellVal = Cells(i, "B").Value Select Case Len(CellVal) - Len(Replace(CellVal, vbLf, "")) Case 3 ' Four lines have three Line Feeds Rows(i).RowHeight = 95 Case 4 ' Five lines have four Line Feeds Rows(i).RowHeight = 85 End Select Next End Sub Note that the RowHeight cannot be set to any arbitrary number... the values it ultimately rounds to depends on the font (has to do with the font needing to occupy an exact number of pixels), so you may not get exactly 85 and 95 points in height when done. -- Rick (MVP - Excel) "ChipButtyMan" wrote in message ... Hi, I have text in a column of rows that is 9 point Lucida Console. Some of the cells in the column contain several rows of text. I want to format the row height something like ; For i = 1 To 1000 If Range("B" & i) = Four Rows Of Text Then RowHeight = 95 If Range("B" & i) = Three Rows Of Text Then RowHeight = 85 End If End If Next i Any help is very much appreciated. |
Format RowHeight question
Thank you Barb & Rick,
both solutions were fine for me but Rick's solution provided the fine tuning I need. Thank you both for your time & expertise. |
All times are GMT +1. The time now is 02:36 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com