'/=============================================/
Sub Variance1()
Dim Actual As Range, std As Range
Dim exptype As String
On Error GoTo exit_Sub
exptype = _
Application.InputBox(Prompt:="Enter e if expense type, " & _
"else blank.", Type:=2)
Set Actual = _
Application.InputBox(Prompt:="Select cell for Actual data.", _
Type:=8)
Set std = _
Application.InputBox(Prompt:="Select cell for Standard data.", _
Type:=8)
If exptype = "e" Then
ActiveCell.Formula = "=-(" & Actual.Address & "/" & std.Address & "-1)"
Else
ActiveCell.Formula = "=" & Actual.Address & "/" & std.Address & "-1"
End If
Selection.Style = "Percent"
exit_Sub:
On Error Resume Next
Set Actual = Nothing
Set std = Nothing
Exit Sub
End Sub
'/=============================================/
HTH,
--
Gary Brown
If this post was helpful, please click the ''''Yes'''' button next to
''''Was this Post Helpfull to you?".
"al" wrote:
Can anybody help me with this macro:
Sub Variance1()
Dim exptype
exptype = InputBox("Enter e if expense type, else blank.")
Dim Actual
Actual = InputBox("Select cell for Actual data.")
Dim Std
Std = InputBox("Select cell for Standard data.")
If exptype = "e" Then
ActiveCell.Formula = "=-(Actual/Std-1)"
Else
ActiveCell.Formula = "=Actual/Std-1"
End If
Selection.Style = "Percent"
End Sub
I want Actual & Std to be the cell address of my selected cells
Am new to excel & not familiar with input box, specially cell addresses
Thxs
Al