Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 349
Default Percentage Calculation using VBA

I want to calculate a percentage change between two cells and it would be
great if I could use the Range(Cells(4,4), Cells(5,4)) format. What is an
easy and clever solution to this problem using VBA code?

Thanks in advance!

/Peter
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Percentage Calculation using VBA


Hello Peter,

The percentage difference is easy to calculate given 2 cells. Simply
divide the smaller value by the larger. However you posted you want the
percent change. That would require more than 2 cells. Are you looking to
examine a 2 groups of data so you have a Delta X column and Delta Y
column?

Thanks,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=482692

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Percentage Calculation using VBA

Something like:

Option Explicit
Sub testme()

Dim myResult As Variant

myResult = "Error!"
With ActiveSheet
If IsNumeric(.Cells(4, 4).Value) Then
If IsNumeric(.Cells(5, 4).Value) Then
If .Cells(5, 4).Value < 0 Then
myResult = .Cells(4, 4).Value / .Cells(5, 4).Value / 100
End If
End If
End If
End With

MsgBox myResult
If IsNumeric(myResult) Then
MsgBox Format(myResult, "0.00%")
End If
End Sub



Peter wrote:

I want to calculate a percentage change between two cells and it would be
great if I could use the Range(Cells(4,4), Cells(5,4)) format. What is an
easy and clever solution to this problem using VBA code?

Thanks in advance!

/Peter


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 349
Default Percentage Calculation using VBA


Thanks Leith for your input!

/Peter
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 349
Default Percentage Calculation using VBA


Thanks Dave for your code!

/Peter
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
Percentage Calculation Chris Excel Worksheet Functions 7 September 3rd 09 12:36 PM
percentage calculation rpi929 Excel Worksheet Functions 3 July 29th 09 06:58 PM
percentage calculation Gabriel Excel Discussion (Misc queries) 1 August 28th 06 09:31 AM
Percentage calculation Roz Excel Discussion (Misc queries) 5 January 6th 06 07:05 PM
Percentage Calculation clandis Excel Worksheet Functions 5 July 21st 05 07:38 PM


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