Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Can not change the numberformat

I try to change the cell number format in my "add in" module using following
statement:

ActiveCell.NumberFormat = "0.00%"

But it does not change the the format, the cell number format was still
"General".

here is my whole code:

Option Explicit

Function numberformat_test()
ActiveCell.NumberFormat = "0.00%"
numberformat_pc_test = 0.234
End Function

1. This code is save in test.xla as a add in file;
2. In Excel, from Tools-Add-Ins, load test.xla;
3. From Excel: Insert-Functions-User Defined category select
numberformat_test function;
4. The cell supposes present 23.4%; but it displays 0.234.


Some friends kindly offered some solutions, but they are only callable in
Macro and should be only resident in local sheet. What I want is an add-in
xla file which can be called by any sheet.

Thanks.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Can not change the numberformat


1. It is not possible to change workspace formatting etc. from within
function. Only a sub routine.

2. This cannot be all your code because you are using Option Explici
which requires declaration of all variables (in this cas
numberformat_pc_test).

3. Your basic function structure is incorrect. You have no argument(s
and no return value which must be the same name as the function

--
Brian

-----------------------------------------------------------------------
BrianB's Profile: http://www.excelforum.com/member.php...tinfo&userid=5
View this thread: http://www.excelforum.com/showthread.php?threadid=27007

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Can not change the numberformat

Thanks BrianB for your kind reply.

Yes, that is not all my code, I just post relative one and try to focus on
the problem.

How can I use sub routine to change the format in add-in xla file?

Cheers.

"BrianB" wrote:


1. It is not possible to change workspace formatting etc. from within a
function. Only a sub routine.

2. This cannot be all your code because you are using Option Explicit
which requires declaration of all variables (in this case
numberformat_pc_test).

3. Your basic function structure is incorrect. You have no argument(s)
and no return value which must be the same name as the function.


--
BrianB


------------------------------------------------------------------------
BrianB's Profile: http://www.excelforum.com/member.php...info&userid=55
View this thread: http://www.excelforum.com/showthread...hreadid=270075


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Can not change the numberformat

You can select your range to change formats and do:

Option Explicit
Sub Changenumberformat_test()
Selection.NumberFormat = "0.00%"
End Sub

Then back to excel and Tools|macro|macros... and run "ChangeNumberFormat_test"



X.Yu wrote:

Thanks BrianB for your kind reply.

Yes, that is not all my code, I just post relative one and try to focus on
the problem.

How can I use sub routine to change the format in add-in xla file?

Cheers.

"BrianB" wrote:


1. It is not possible to change workspace formatting etc. from within a
function. Only a sub routine.

2. This cannot be all your code because you are using Option Explicit
which requires declaration of all variables (in this case
numberformat_pc_test).

3. Your basic function structure is incorrect. You have no argument(s)
and no return value which must be the same name as the function.


--
BrianB


------------------------------------------------------------------------
BrianB's Profile: http://www.excelforum.com/member.php...info&userid=55
View this thread: http://www.excelforum.com/showthread...hreadid=270075



--

Dave Peterson

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
.numberformat Q Aaron Excel Worksheet Functions 4 December 18th 09 02:15 AM
numberformat? Jack Sons Excel Discussion (Misc queries) 3 September 4th 07 03:44 PM
NumberFormat? alex Excel Worksheet Functions 3 March 1st 07 09:12 PM
Can not change the numberformat X.Yu Excel Programming 6 October 18th 04 09:19 AM
Numberformat Syrus the Virus[_13_] Excel Programming 6 February 12th 04 02:12 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"