1

I want to get the result of a formula contained in a cell, but I always get 0 returned, instead of the real results.

I have the following:

Set c = .Cells (5,5)

MsgBox (c.Formula) ' this return the following: = ASIN (W22-V22/$D$7)*180/PI() 
MsgBox (c.Value) ' this returns 0
MsgBox (c.Value2) ' this returns 0 as well

And even if I try with Evaluate:

evaluation = Application.Evaluate (c.Formula) 
MsgBox (c.Value) ' it still returns 0
Leon
  • 255
  • 1
  • 4
  • 11

2 Answers2

1

Zero is the correct answer if both V22 and W22 are zero.

Gary's Student
  • 95,722
  • 10
  • 59
  • 99
0

Maybe try this:

Sub formVal()

Dim c As Range

Set c = ThisWorkbook.Sheets(1).Cells(5, 5)

MsgBox (c.Formula) 
MsgBox (c.Value)
MsgBox (c.Value2)



End Sub
Tom K.
  • 1,020
  • 1
  • 12
  • 28
  • I see no changes, but I tried it and it did return the same results as before: 0 all the time – Leon Mar 03 '15 at 13:56
  • Maybe you've got your row or column ID wrong? It's Cells(rowIndex, columnID). You can also write: c =...Cells("E5") – Tom K. Mar 03 '15 at 14:04
  • And just btw, isn't your formula supposed to be =ASIN((W22-V22)/$D$7)*180/PI() ? – Tom K. Mar 03 '15 at 14:10
  • See here: http://stackoverflow.com/questions/17745656/does-value-value-act-similar-to-evaluate-function-in-vba?rq=1 – Tom K. Mar 03 '15 at 14:26