Leon
Leon

Reputation: 255

VBA - How to get the result of a formula ? (.Value always returns 0)

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

Upvotes: 1

Views: 6862

Answers (2)

Tom K.
Tom K.

Reputation: 1042

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

Upvotes: 0

Gary's Student
Gary's Student

Reputation: 96773

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

Upvotes: 1

Related Questions