Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Brayden Smith   on Nov 06 In MS Office Category.

  
Question Answered By: Volney Fischer   on Nov 06

MAX and SQRT are worksheet functions, not VBA functions. Some worksheet
functions can be used in your VBA code, if you specify them as
Application.WorksheetFunction.FUNCTION, where FUNCTION is one of the available
worksheet functions. With this change, your code looks like this:

Sub xformula()
Dim i As Double, k As Double, q As Double
q = Worksheets("input").Range("e12").Value
For i = 1 To q
k = Worksheets("input").Cells(14 + i, 6).Value
Cells(11 + i, 7).Value = 1 + (Application.WorksheetFunction.Max(Cells(11
+ i, 5).Value, 0.2) - 1) / Application.WorksheetFunction.Sqrt(k)
Next i
End Sub

I haven't tested this, but it compiles correctly. Also, SQRT() applied to to
negative number will generate an error.

Share: 

 

This Question has 5 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Why math functions do not work? Or get search suggestion and latest updates.


Tagged: