Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Max Max is offline
external usenet poster
 
Posts: 390
Default UDF is not working

Hi , i create UDF mypc which gives percent of the passed number as i need to
change the number format of given cell on some calculation,


function mypc(rng as long)
mypc=format(rng,"percent")
end function

Suppose In worksheet , A1 contains value 5

In B2, i type = mypc(A1) - RETURNS 500%, but i am not able to perform
calculation on this returned values.

please help
Thanx
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default UDF is not working

Hi Max,

The returned value is text, with which you can't calculate directly.
You can use

=VALUE(mypc(A1))

or, if you want the format to show, =VALUE(B1) if the formula is in B1

In case you wanted to ask; you cannot format a cell from a function.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel


"Max" wrote in message ...
| Hi , i create UDF mypc which gives percent of the passed number as i need to
| change the number format of given cell on some calculation,
|
|
| function mypc(rng as long)
| mypc=format(rng,"percent")
| end function
|
| Suppose In worksheet , A1 contains value 5
|
| In B2, i type = mypc(A1) - RETURNS 500%, but i am not able to perform
| calculation on this returned values.
|
| please help
| Thanx


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,440
Default UDF is not working

<with which you can't calculate directly

That's not entirely true. Some operations do accept text, but some functions fail. So it's better to convert it to a number using
VALUE or multiply it by 1, for example.

--
Kind regards,

Niek Otten
Microsoft MVP - Excel

"Niek Otten" wrote in message ...
| Hi Max,
|
| The returned value is text, with which you can't calculate directly.
| You can use
|
| =VALUE(mypc(A1))
|
| or, if you want the format to show, =VALUE(B1) if the formula is in B1
|
| In case you wanted to ask; you cannot format a cell from a function.
|
| --
| Kind regards,
|
| Niek Otten
| Microsoft MVP - Excel
|
|
| "Max" wrote in message ...
|| Hi , i create UDF mypc which gives percent of the passed number as i need to
|| change the number format of given cell on some calculation,
||
||
|| function mypc(rng as long)
|| mypc=format(rng,"percent")
|| end function
||
|| Suppose In worksheet , A1 contains value 5
||
|| In B2, i type = mypc(A1) - RETURNS 500%, but i am not able to perform
|| calculation on this returned values.
||
|| please help
|| Thanx
|
|


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
Calculate working days but change working week SamB Excel Discussion (Misc queries) 1 September 1st 08 09:17 PM
Making weekend days working days - the system cuts the working tim Fluffy Excel Discussion (Misc queries) 1 May 30th 08 10:02 PM
Newly created Get Function is not working when I copied the syntax from a working function CJ Excel Programming 1 January 16th 07 05:28 AM
Macro working in Excel 2003; not working in Excel 2000 Leslie Barberie Excel Programming 5 May 20th 04 07:51 PM
Adding sales from a non working day to the previous working day Alex Excel Programming 1 September 19th 03 08:48 AM


All times are GMT +1. The time now is 02:27 PM.

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"