Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default User Defined Range

I have a UDF that calculates the percentage of a value (rVal) based on
a sum of similar values (rTot).
It returns a value multipled by another value (rTarg) and rounded.

Function FigurePert(rTot As Integer, rVal As Integer, rTarg) As
Variant
xx = (rVal / rTot)
FigurePert = Round(xx * rTarg, 0)
End Function

I would like rTot be the value of a given range that the user chooses
by a defined Name or selected.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default User Defined Range

It's always better to supply input to the function via arguments, the way
you do now. That is the only way Excel can determine dependencies. Any other
way cells may not recalculate when needed or in the wrong order.
Sometimes adding Application.Volatile is suggested as a solution, but there
is no guarantee this will always work correctly and potentially it
calculates too often.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel


"caveman.savant" wrote in message
...
I have a UDF that calculates the percentage of a value (rVal) based on
a sum of similar values (rTot).
It returns a value multipled by another value (rTarg) and rounded.

Function FigurePert(rTot As Integer, rVal As Integer, rTarg) As
Variant
xx = (rVal / rTot)
FigurePert = Round(xx * rTarg, 0)
End Function

I would like rTot be the value of a given range that the user chooses
by a defined Name or selected.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default User Defined Range

The range can be large and dynamic so typing in the values would be
difficult

On Feb 13, 6:45*am, "Niek Otten" wrote:
It's always better to supply input to the function via arguments, the way
you do now. That is the only way Excel can determine dependencies. Any other
way cells may not recalculate when needed or in the wrong order.
Sometimes adding Application.Volatile is suggested as a solution, but there
is no guarantee this will always work correctly and potentially it
calculates too often.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"caveman.savant" wrote in message

...



I have a UDF that calculates the percentage of a value (rVal) based on
a sum of similar values (rTot).
It returns a value multipled by another value (rTarg) and rounded.


Function FigurePert(rTot As Integer, rVal As Integer, rTarg) As
Variant
* *xx = (rVal / rTot)
* *FigurePert = Round(xx * rTarg, 0)
End Function


I would like rTot be the value of a given range that the user chooses
by a defined Name or selected.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default User Defined Range

You don't have to type the vales, just supply a reference to the range as an
argument to the function.

But what do you want the function to do with rTot? It is defined an Integer
now, I don't see what it should do with a range.
BTW, use Long instead of Integer to avoid overflow and improve calculation
speed.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"caveman.savant" wrote in message
...
The range can be large and dynamic so typing in the values would be
difficult

On Feb 13, 6:45 am, "Niek Otten" wrote:
It's always better to supply input to the function via arguments, the way
you do now. That is the only way Excel can determine dependencies. Any
other
way cells may not recalculate when needed or in the wrong order.
Sometimes adding Application.Volatile is suggested as a solution, but
there
is no guarantee this will always work correctly and potentially it
calculates too often.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"caveman.savant" wrote in message

...



I have a UDF that calculates the percentage of a value (rVal) based on
a sum of similar values (rTot).
It returns a value multipled by another value (rTarg) and rounded.


Function FigurePert(rTot As Integer, rVal As Integer, rTarg) As
Variant
xx = (rVal / rTot)
FigurePert = Round(xx * rTarg, 0)
End Function


I would like rTot be the value of a given range that the user chooses
by a defined Name or selected.


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
User-defined range for graph royend Excel Discussion (Misc queries) 3 September 4th 07 09:11 AM
How to: User Form to assign a user defined range to a macro variab TrevTrav Excel Programming 1 March 22nd 05 07:57 PM
User-defined data type; Error: Only User-defined types... tiger_PRM Excel Programming 1 July 18th 04 03:32 PM
external range in VBA (user defined formula) BrianB Excel Programming 2 July 23rd 03 06:25 PM
external range in VBA (user defined formula) Tim Zych[_2_] Excel Programming 0 July 22nd 03 02:02 AM


All times are GMT +1. The time now is 12:25 AM.

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"