Go Premium for a chance to win a PS4. Enter to Win

x
Solved

# DateValue function

Posted on 2013-12-13
Medium Priority
346 Views
Folks,
Can the DATEVALUE function reference a cell address such as A3 rather than be hard coded?
0
Question by:Frank Freese
• 3
• 3

LVL 81

Expert Comment

ID: 39718234
Of course it can.

What data does the cell contain in your workbook that DATEVALUE cannot convert?
0

Author Comment

ID: 39718253
Let's say A3:A40 are dates: 11/01/2013 - 11/30/2013
In cell C2 I would like to enter in a date: 11/15/2013
In cells B3:B40 are various product numbers many repeated for some products might have more sales during this time period.
In cell D2 I enter in a product number: K7896
F2 will tell me how many of a product I sold in that day.
I tried to do this in F2:
{=SUM((DATEVALUE(Range("C2"))=\$A\$3:\$A\$40)*(Range("D2")=\$B\$3:\$B\$40)}

I get a #VALUE error in F2

I know I could use filters but I'm trying to do this with a formula.
0

LVL 81

Accepted Solution

byundt earned 2000 total points
ID: 39718260
Your problem is with Range("C2"). This is VBA syntax, and does not work in a worksheet formula. The worksheet equivalent is INDIRECT("C2").

What I suggest instead is a regular formula using SUMPRODUCT:
=SUMPRODUCT((C2=\$A\$3:\$A\$40)*(D2=\$B\$3:\$B\$40))     if C2 is a date formatted like you showed
=SUMPRODUCT((DATEVALUE(C2)=\$A\$3:\$A\$40)*(D2=\$B\$3:\$B\$40))        if C2 is text
0

Author Comment

ID: 39718781
One question here....would this be an array formula?
0

LVL 81

Expert Comment

ID: 39718784
The SUMPRODUCT formula is an array formula that does not need to be array-entered.

If the formula is not working for you, could you please post a sample workbook that demonstrates the problem? It doesn't need more than five rows of data.
0

Author Closing Comment

ID: 39718787
I answered my own last question.
Great...two options for one problem.
Thank you very much
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Do you use a spreadsheet like Microsoft's Excel?  Have you ever wanted to link out to a non excel file on your computer or network drive?  This is the way I found to do it!
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
###### Suggested Courses
Course of the Month9 days, 20 hours left to enroll