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

Dear friends,
The following code will show result in percentage with left aligned(TEXT) in
excel. My requirement is that the result should be in number format right
aligned with the same percentage symbol along with the result. ( rather than
text with left aligned)

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

Will any one guide me with the correct code for my requirement with required
modification.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default request code for right align and percentage

Hi,

Range("a1")=CAGR(....) will be right-aligned as percentage

What are the values of FirstValue and LastValue as the logic doesn't appear
to be correct regarding Range.

"srinivasan" wrote:

Dear friends,
The following code will show result in percentage with left aligned(TEXT) in
excel. My requirement is that the result should be in number format right
aligned with the same percentage symbol along with the result. ( rather than
text with left aligned)

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

Will any one guide me with the correct code for my requirement with required
modification.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default request code for right align and percentage

Hi Toppers,

Thank you for your immediate response. Range is (First Value :Last
Value)which represents pv for present value and fv for future value of rate
function.
The correction to the code for right alignment with percentage symbol next
to the value may please be guided.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default request code for right align and percentage

Hi,
Why use a user function when you can simply DO:


CAGR= Application.WorksheetFunction.Rate(Count, 0, -(FirstValue), LastValue)

And sssign CAGR to wherever in your code:

e.g. Range("B3")=Format(CAGR,"00.00%")


"srinivasan" wrote:

Hi Toppers,

Thank you for your immediate response. Range is (First Value :Last
Value)which represents pv for present value and fv for future value of rate
function.
The correction to the code for right alignment with percentage symbol next
to the value may please be guided.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 30
Default request code for right align and percentage

Hi Toppers,

Again thank you for your response. I am new to VBA and just entering. Kindly
give me the full code according to your advice. I can"t understand
Range("B3"). Once again Thank you in advance.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,339
Default request code for right align and percentage

Hi,
Range("b3") means you want to place your answer in Cell B3. Where do
you want the result of your calculation to go?


"srinivasan" wrote:

Hi Toppers,

Again thank you for your response. I am new to VBA and just entering. Kindly
give me the full code according to your advice. I can"t understand
Range("B3"). Once again Thank you in advance.



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
Request for a code FARAZ QURESHI Excel Discussion (Misc queries) 0 January 27th 08 02:59 PM
CF in VB Code - Simple Request Kevin Baker[_2_] Excel Programming 2 May 2nd 05 12:34 PM
text align code XL2000 Jess Excel Programming 3 March 31st 05 04:01 PM
quick code request michelle Excel Programming 1 June 23rd 04 09:59 AM
Request Vba code Export gif file Luigi[_2_] Excel Programming 3 February 17th 04 12:52 PM


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