Result of DAY formula as variable

bukimi

Board Regular
Joined
Apr 12, 2017
Messages
105
Office Version
  1. 2019
Platform
  1. Windows
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:

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
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:
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,987
Members
452,373
Latest member
TimReeks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top