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
|