View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Applying formulae

What did you enter as the formula? I'm betting that something was wrong with
it. And excel would have yelled if you did it manually.

Depending on the formula, this might head off some errors:

Option Explicit
Sub myFormlae()
Dim sformula As Variant
sformula = InputBox("Supply formula (inlclude the leading =)")
If Not IsEmpty(sformula) Then
If Left(sformula, 1) < "=" Then
sformula = "=" & sformula
End If
If IsError(Evaluate(sformula)) Then
MsgBox "Hey, that can't be right"
Exit Sub
Else
Selection.Formula = sformula
End If
End If
End Sub

ian123 wrote:

Thanks but there is a problem with the line
"Selection.Formula = sformula"
which results is an application defined or object defined error

Any ideas?

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson