Results 1 to 3 of 3

Thread: Result of DAY formula as variable

  1. #1
    Board Regular
    Join Date
    Apr 2017
    Posts
    82
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Result of DAY formula as variable

    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 by bukimi; Oct 4th, 2018 at 02:40 AM.

  2. #2
    MrExcel MVP FormR's Avatar
    Join Date
    Aug 2011
    Location
    UK
    Posts
    6,089
    Post Thanks / Like
    Mentioned
    24 Post(s)
    Tagged
    2 Thread(s)

    Default Re: Result of DAY formula as variable

    Hi, you could try:

    Code:
    myvariable = day(worksheetfunction.Max(sheets("Values").Columns(8)))
    Quote Originally Posted by bukimi View Post
    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 by FormR; Oct 4th, 2018 at 03:17 AM.
    [code]your code[/code]

  3. #3
    Board Regular
    Join Date
    Apr 2017
    Posts
    82
    Post Thanks / Like
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Result of DAY formula as variable

    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.

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •