Solved

# Value from a cell used in a module

Posted on 2014-08-20
68 Views
Folks,
In my worksheet at P13 there's this following function:
=COVAR(M6:M13,N6:N13). With the provided data this returns a value of 16.25 is returned as a positive number. P13 is a dynamic value.
The code below says that the value in P13 is empty at line 3? The code is a modular and is attached to an form radio button object.
``````Sub EvalCovarPositive()

If Range("P13").Value > 0 Then
MsgBox ("Correct - a positive Covariance indicates that the values move together")
Else
MsgBox ("Incorrect - When a value is negative the Covariance indicates that the values move inversely")
End If
End Sub
``````
0
Question by:Frank Freese

LVL 47

Accepted Solution

Hi,

the code is fine, maybe you should define the sheet

Sub EvalCovarPositive()

If Worksheets("Sheet1").Range("P13").Value > 0 Then
MsgBox ("Correct - a positive Covariance indicates that the values move together")
Else
MsgBox ("Incorrect - When a value is negative the Covariance indicates that the values move inversely")
End If
End Sub

Regards
0

Author Comment

Do you think it would help if I referenced the correct cell add P14 and not P13......it made a big difference. Stupidity is in the eye of the beholder as I stand in front of the mirror.

Thanks in affirming my code was not the problem.
0

Author Closing Comment

Thanks - I appreciate your help!
0

## Featured Post

### Suggested Solutions

Running Out of IP Addresses 9 95
25th of every month 7 38
Excel to create SQL insert 7 28
I've recently been in need of an Excel macro that could add a letter before the text on multiple cells in an Excel document. My English is as it is, so I will try explain what it does diffrently. If you have an excel document with 2000 rows an…
How to quickly and accurately populate Word documents with Excel data, charts and images (including Automated Bookmark generation) David Miller (dlmille) Synopsis In this article you’ll learn how to use ExcelToWord! to copy data,charts, shapes …
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.