Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
Percentage Calculation using VBA
Thanks Leith for your input! /Peter |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Percentage Calculation using VBA
Thanks Dave for your code! /Peter |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Percentage Calculation | Excel Worksheet Functions | |||
percentage calculation | Excel Worksheet Functions | |||
percentage calculation | Excel Discussion (Misc queries) | |||
Percentage calculation | Excel Discussion (Misc queries) | |||
Percentage Calculation | Excel Worksheet Functions |