Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default modification for the code

Hi
The following code will show result in percentage with left aligned(TEXT) in
excel. My requirement is that the result should be right aligned (in number
format)
with the same percentage symbol along with the result. ( rather than
text with left aligned). Otherwise the code works fine and no change is
required.

Public Function CAGR(FirstValue, LastValue)
Dim fv, lv, v As Double
Set r = Application.Range(FirstValue, LastValue)
Count = (Application.Range(FirstValue, LastValue).Count - 1)
CAGR = FirstValue
v = Application.WorksheetFunction.Rate(Count, 0, -(FirstValue), LastValue)
CAGR = Format(v, "00.00%")
End Function

I am repeatedly asking for help but no avail. Will any one familiar with
this area would kindly help me. As I am not familar with the VBA and got this
thro one of my friend I am helpless.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default modification for the code


Although your code works fine it is also a bit ugly

but you should look at:
HorizontalAlignment = xlRight

Tip: if you start the macro editor and record a macro doing what yopu
want to achieve and stop it the vba code of this macro is stored in a
new module.


--
Dnereb
------------------------------------------------------------------------
Dnereb's Profile: http://www.excelforum.com/member.php...o&userid=26182
View this thread: http://www.excelforum.com/showthread...hreadid=397464

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default modification for the code

Just change this line

CAGR = Format(v, "00.00%")

to

CAGR = v

and format the cell in Excel. A UDF cannot format the cell, just return an
answer.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"srinivasan" wrote in message
...
Hi
The following code will show result in percentage with left aligned(TEXT)

in
excel. My requirement is that the result should be right aligned (in

number
format)
with the same percentage symbol along with the result. ( rather than
text with left aligned). Otherwise the code works fine and no change is
required.

Public Function CAGR(FirstValue, LastValue)
Dim fv, lv, v As Double
Set r = Application.Range(FirstValue, LastValue)
Count = (Application.Range(FirstValue, LastValue).Count - 1)
CAGR = FirstValue
v = Application.WorksheetFunction.Rate(Count, 0, -(FirstValue), LastValue)
CAGR = Format(v, "00.00%")
End Function

I am repeatedly asking for help but no avail. Will any one familiar with
this area would kindly help me. As I am not familar with the VBA and got

this
thro one of my friend I am helpless.



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
modification to this code James Excel Discussion (Misc queries) 0 March 23rd 09 09:20 PM
Code modification help AndyMP Excel Worksheet Functions 1 February 8th 09 11:41 PM
Code Modification Todd Huttenstine Excel Programming 1 March 7th 04 03:54 AM
Sort Code Modification Todd Huttenstine\(Remote\) Excel Programming 1 November 27th 03 08:18 AM
Modification to code Peter Atherton Excel Programming 1 September 23rd 03 07:36 PM


All times are GMT +1. The time now is 06:31 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"