Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8426919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:39:34+00:00 2026-06-10T04:39:34+00:00

I have a VBA function within a spreadsheet which operates on another spreadsheet that

  • 0

I have a VBA function within a spreadsheet which operates on another spreadsheet that is opened in an earlier stage of my macro. The macro used to work fine but just recently has started causing a 1004 error (“Unable to get RoundDown property of the WorksheetFunction class”) when it runs.

I believe I understand what the error would be caused by (a problem running RoundDown) but I cannot see why it is getting triggered in my macro and the odd part is that when I go into Debug mode and step through the code in the VBE the error does not recur (despite nothing obviously changing).

Does anyone have a similar experience of this sort of error occuring inconsistently and know what I could do to resolve it?

I’m reasonably VBA/Excel-savvy, but any suggestions on further steps to diagnose it would be appreciated. I am wondering if there is some issue with the opened spreadsheet not being ready but I cannot see how.

The code is here. The error occurs on the line marked with a comment.

Public Function GetDatesA(sWorkbookname As String, sSheetname As String, sCell As String) As Variant

    Dim vDateList() As Variant
    Dim currentCell As Range
    Dim n As Long

    Set currentCell = Workbooks(sWorkbookname).Worksheets(sSheetname).Range(sCell)

    n = 0

    Do
        If Trim(currentCell.Value) = "" Then
            Exit Do
        Else
            ReDim Preserve vDateList(0 To 1, 0 To n)
            vDateList(0, n) = WorksheetFunction.RoundDown(currentCell.Value, 0) 'error occcurs on this line
            vDateList(1, n) = currentCell.Column
            'Debug.Print currentCell.Value
        End If
        Set currentCell = currentCell.Offset(0, 1)
        n = n + 1
    Loop While currentCell.Column < XL_LAST_COLUMN

    GetDatesA = vDateList

End Function

Other details are:

  • Excel version: 2010

  • File being opened resides locally on my C: drive; my macro is in a spreadsheet on the network

  • File format for both files is .xls (i.e. Excel 2003) – I don’t have the option of changing this

  • Windows 7 (not that I think it would be relevant)

Two points I’ve tried already are:

  • Substitute a different worksheet function (e.g. Min(currentCell)) and that also causes the same problem

  • Having the file open already seems to stop the problem – I wonder if there is some way that the workbook which is being opened (rather than my main workbook with the macro in it) is not enabled for macros and this is interfering. But even if this is the cause I’m not sure how to get around it!

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:39:35+00:00Added an answer on June 10, 2026 at 4:39 am

    This error occurs often when any argument passed to the worksheet function is not of the correct type or simply doesn’t make sense.

    For example, I’ve had this problem when calling WorksheetFunction.Asin with an argument bigger than 1. In your case, I’d guess currentCell.Value is a non-numeric value or one not according to your region settings regarding numbers.

    Yes, the error message is really misguiding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a VBA macro in an excel spreadsheet that opens all workbooks
Say I have a button embedded into my spreadsheet that launches some VBA function.
I have a VBA Word Macro that gets words from .txt list and color
I have a VBA function IsValidEmail() that returns a boolean. I have a query
I have an EXCEL VBA function which should return the address of the first
I have some VBA code that opens a webpage, then calls a javascript function
I have a UDF non-volatile function in VBA, which requires a global variable (callback
I have an Excel VBA function that takes a number of optional parameters, including
We have developed a consolidation function that will be used by other processes and
I have a spreadsheet which contains 'unique' IDs. The problem is that they are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.