Function for RowHt. How to create

K

Kieranz

Hi All,
I would like to create a function to get the row height. Eg in cell B5
it should put the value of row B height. similar to =Cell("width") so
that if i type =RowHt() it should put the row height value in the
activecell.
Many Thks
KZ
 
G

Guest

Public Function RowHt() As Double
RowHt = ActiveCell.EntireRow.Height
End Function

note that adjusting the row height will not cause the cell to recalculate..
just like Cell("width") when getting the column width.
 
J

JE McGimpsey

One way:

Public Function RowHeight(Optional ByRef rng As Range) As Variant
Application.Volatile
On Error Resume Next
If rng Is Nothing Then Set rng = Application.Caller
On Error GoTo 0
If Not rng Is Nothing Then
RowHeight = rng.EntireRow.Height
Else
RowHeight = CVErr(xlErrRef)
End If
End Function

Called as

=RowHeight()

it returns the height of the active row, or you can reference another
cell/row:

=RowHeight(E7)

returns the height of Row 7.
 
K

Kieranz

Public Function RowHt() As Double
RowHt = ActiveCell.EntireRow.Height
End Function

note that adjusting the row height will not cause the cell to recalculate..
just like Cell("width") when getting the column width.


Many thks
Rgds
KZ
 
K

Kieranz

One way:

Public Function RowHeight(Optional ByRef rng As Range) As Variant
Application.Volatile
On Error Resume Next
If rng Is Nothing Then Set rng = Application.Caller
On Error GoTo 0
If Not rng Is Nothing Then
RowHeight = rng.EntireRow.Height
Else
RowHeight = CVErr(xlErrRef)
End If
End Function

Called as

=RowHeight()

it returns the height of the active row, or you can reference another
cell/row:

=RowHeight(E7)

returns the height of Row 7.


Many thks, Mr McGimpsey. Exactly what i wanted. Qn What does
application.caller do? and CVErr(xlErrRef)
Rgds
KZ
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top