Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default 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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,355
Default 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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default 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.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default 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.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is RowHeight=0 the same as Hidden Michelle Excel Discussion (Misc queries) 4 February 22nd 10 02:02 PM
Find 4.75 and Replace with 12.75 ( Rowheight ) Steved Excel Discussion (Misc queries) 2 June 5th 08 02:34 AM
How can I find the rowheight and use it in a formula? [email protected] Excel Programming 2 August 11th 07 12:47 AM
Slow RowHeight behavior [email protected] Excel Programming 2 August 22nd 06 05:28 PM
Automatically changing the rowheight Ajit[_4_] Excel Programming 2 February 26th 04 03:01 PM


All times are GMT +1. The time now is 04:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"