Row Height Function

S

Steve S

Hey all... I can't figure out what I'm doing wrong here.
Please help!

I have the following under the 'This Workbook' in VBEditor:

Function RowHeight() As Double
RowHeight = Application.Caller.RowHeight
End Function

Then, in the worksheet, I've entered =RowHeight() and I
get the dreaded #NAME? error. Any quick responses would
be incredibly helpful. TIA
 
F

Frank Kabel

Hi
a function can't change the formating of a cell or change the Excel
environment. So what you're trying to achieve is not possible. Sorry

In addition you have to enter your user defined functions in a standard
module and not in 'ThisWorkbook'. Insert a new module in the VBA editor
and enter your code in this standard module. You may also have a look
at
http://www.mvps.org/dmcritchie/excel/getstarted.htm
 
J

JE McGimpsey

You should put this in a regular code module (in the VBE:
Insert/Module). In general, ThisWorkbook and worksheet class modules
should be used for event macros.

The ThisWorkbook module is a workbook-class module. If you, for some
reason, want to leave the code there, you need to prepend the class name:

=ThisWorkbook.RowHeight()
 
F

Frank Kabel

Hi
sorry
I misread your function Thought you'e trying to set the row height.
Just put your code in a standard module and it should work.
 
J

JE McGimpsey

Frank Kabel said:
a function can't change the formating of a cell or change the Excel
environment. So what you're trying to achieve is not possible. Sorry

The function wasn't changing anything, just returning the row height.
In addition you have to enter your user defined functions in a standard
module and not in 'ThisWorkbook'. Insert a new module in the VBA editor
and enter your code in this standard module. You may also have a look
at
http://www.mvps.org/dmcritchie/excel/getstarted.htm

You don't have to enter UDFs in standard modules, but if you use
Workbook or worksheet code modules, you need to prepend the class name,
just like any other class macro.
 
F

Frank Kabel

JE McGimpsey said:
Sorry

The function wasn't changing anything, just returning the row height.

Je
saw this after sending the message :)
Need more coffee, I think <vbg>

Frank
 

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