Excel error 1004 “Unable to get … property of WorksheetFunction class” appearing inconsistently

后端 未结 3 549
攒了一身酷
攒了一身酷 2020-11-30 12:02

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 recent

相关标签:
3条回答
  • 2020-11-30 12:51

    I have come accross this before, and for me it was becase the criteria range made no sense, as Andre said above.

    See example formula below: .Cells(11, i).Formula = Application.WorksheetFunction.CountIfs(Sheets("Sheet1").Range("AC8:C" & n), "S")

    Have a look at the Range... it makes no sense. Amended the range from "AC8:C" to "AC8:AC" and it will work perfectly

    0 讨论(0)
  • 2020-11-30 13:02

    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 讨论(0)
  • 2020-11-30 13:08

    I got the "Unable to get * property of WorksheetFunction Class" error using Transpose, MMult,MDterm, and MInverse functions.

    I was able to get my code to run by putting "Option Base 1" in the Declarations (before the actual code) section of the particular Module in the Editer.

    Excel assumes "Option Base 0" which will add an extra row and column of empty cells. This will cause the error to occur and isn't immediately obvious to see.

    0 讨论(0)
提交回复
热议问题