Row height

G

greg7468

Hello all,
Is there any way you can set the row heights, apart from doing i
manually.
What I am looking for is say the row height of row 1 to be set to th
value in cell A1, row 2 height set to the value in B1 etc.
Thanks very much in advance
 
D

Don Guillett

One way would be to right click sheet tab>view code>copy/paste this>modify
to suit>SAVE

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$A$1" Then Rows(1).RowHeight = Target
If Target.Address = "$B$1" Then Rows(2).RowHeight = Target

End Sub
 
G

greg7468

Thanks Don,
That is exactly what I needed, being a bit new to VBA if I had to d
the same for 50 rows would I have to re-write the code and change t
suit for each row or is there a quicker way.

Thanks again, Greg
 
D

Don Guillett

How about this one installed the same way.
Now if you double click any cell in Column A, the row height will be what is
in cell a1.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Column = 1 Then Target.RowHeight = Range("a1")
End Sub
 
G

greg7468

Thanks again Don,
however, all 50 rows are likely to be different heights, I jus
wondered whether there was a quick way of writing the code for 50 row
without doing each line of code individually.
Greg
 
D

Don Guillett

I guess I don't understand. Are you to have 50 different cells for the 50
different rows?
Perhaps a SMALL workbook sent privately to me.
 
D

Dave Peterson

The rowheights are all in row 1 going across (a1, b1, c1,...)

then how about:

Option Explicit
Sub testme()

Dim myCell As Range
Dim wks As Worksheet

Set wks = ActiveSheet

With wks
For Each myCell In .Range("a1", _
.Cells(1, .Columns.Count).End(xlToLeft))
If IsNumeric(myCell.Value) Then
If myCell.Value >= 0 _
And myCell.Value <= 409 Then
.Rows(myCell.Column).RowHeight = myCell.Value
End If
End If
Next myCell
End With

End Sub
 
Top