Consulting

Results 1 to 3 of 3

Thread: Solved: Using the EOMonth Function

  1. #1

    Solved: Using the EOMonth Function

    I get an error when I attempt to use the EOMonth Function. I've pasted both the creation of the array and the attempt to extract a value and use the function. Thank you for your help.


    [VBA]
    For ACounter = 2 To DataCount
    MultiArr(ACounter, 2) = Format(Cells(ACounter, 2).Value, "mm/dd/yyyy")
    Next ACounter

    Dim TestDate As Date
    Dim SecondDate As Date
    Dim abc As Integer

    For abc = 2 To DataCount
    If MultiArr(abc, 1) = "ThisOne" Then
    TestDate = MultiArr(abc, 2)
    SecondDate = WorksheetFunction.EOMonth(TestDate)
    Else
    End If
    Next abc
    [/VBA]

    Edited 10-Apr-07 by geekgirlau. Reason: insert vba tags

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Do you have Analysis ToolPak loaded?
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    EOMONTH is not a worksheet function exposed to VBA.

    [vba]

    For ACounter = 2 To DataCount
    MultiArr(ACounter, 2) = Format(Cells(ACounter, 2).Value, "mm/dd/yyyy")
    Next ACounter

    Dim testDate As Date
    Dim SecondDate As Date
    Dim abc As Integer

    For abc = 2 To DataCount
    If MultiArr(abc, 1) = "ThisOne" Then
    testDate = MultiArr(abc, 2)
    SecondDate = DateSerial(Year(testDate), Month(testDate) + 1, 0)
    Else
    End If
    Next abc
    [/vba]

Posting Permissions

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