% variance calculation
Thxs a lot Patrick !!
Patrick Molloy wrote:
two ways to fix this
Option Explicit
Sub Macro1()
Dim exptype As String
exptype = InputBox("Enter e if expense type.")
ActiveCell.FormulaR1C1 = _
"=IF(""" & exptype & """=""e"",-(RC[-1]/RC[-2]-1),RC[-1]/RC[-2]-1)"
End Sub
Sub Macro1_new()
Dim exptype As String
exptype = InputBox("Enter e if expense type.")
If UCase(exptype) = "E" Then
ActiveCell.FormulaR1C1 = "=-(RC[-1]/RC[-2]-1)"
Else
ActiveCell.FormulaR1C1 = "=(RC[-1]/RC[-2]-1)"
End If
End Sub
The secnd example is far easier to understand and this debug at some future
date
"al" wrote:
Can anybody help me to correct this macro:
Sub Macro1()
Dim exptype
exptype = InputBox("Enter e if expense type.")
ActiveCell.FormulaR1C1 =
"=IF(exptype=""e"",-(RC[-1]/RC[-2]-1),RC[-1]/RC[-2]-1)"
End Sub
Am getting error #NAME?
I do not want to refer exptype to any cell as it's only a general input
Thxs
|