ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Function for RowHt. How to create (https://www.excelbanter.com/excel-programming/387514-function-rowht-how-create.html)

Kieranz[_2_]

Function for RowHt. How to create
 
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


Vergel Adriano

Function for RowHt. How to create
 

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.

--
Hope that helps.

Vergel Adriano


"Kieranz" wrote:

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



JE McGimpsey

Function for RowHt. How to create
 
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.


In article om,
"Kieranz" wrote:

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


Kieranz[_2_]

Function for RowHt. How to create
 
On Apr 16, 8:18 pm, Vergel Adriano
wrote:
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.

--
Hope that helps.

Vergel Adriano





"Kieranz" wrote:
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



Many thks
Rgds
KZ


Kieranz[_2_]

Function for RowHt. How to create
 
On Apr 16, 8:25 pm, JE McGimpsey wrote:
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.

In article om,





"Kieranz" wrote:
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



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


JE McGimpsey

Function for RowHt. How to create
 
Did you look at "Caller property" and "CVErr Method" in XL/VBA Help?



In article .com,
"Kieranz" wrote:

Qn What does
application.caller do? and CVErr(xlErrRef)



All times are GMT +1. The time now is 05:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com