Result of DAY formula as variable

bukimi

Board Regular
Joined
Apr 12, 2017
Messages
85
Hello!

I got a formula in my cell assigned via VBA:
Code:
ActiveCell.FormulaR1C1 = "=DAY(MAX(values!C8))"
It finds the highest number of day among all values in the column.

I want it to be my variable without having this value in a cell.
I looked into Worksheetfunction options, but it seems that DAY formula isn't available there. Is there a workaround for such cases or I'm forced to use a cell for it (and then empty it)?
 
Last edited:

Some videos you may like

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

FormR

MrExcel MVP
Joined
Aug 18, 2011
Messages
6,412
Office Version
365
Platform
Windows
Hi, you could try:

Code:
myvariable = day(worksheetfunction.Max(sheets("Values").Columns(8)))
I looked into Worksheetfunction options, but it seems that DAY formula isn't available there.


VBA has it's own native Day() function.
 
Last edited:

bukimi

Board Regular
Joined
Apr 12, 2017
Messages
85
Wow, since I was already using DAY in VBA, I'm ashamed for not thinking about that. Never thought about mixing native function with Worksheetfunction result.
Simple and smart.

Thank you! Very good lesson for me.
 

Watch MrExcel Video

Forum statistics

Threads
1,102,542
Messages
5,487,469
Members
407,602
Latest member
clang663

This Week's Hot Topics

Top