JR_Chicago
New Member
- Joined
- Apr 20, 2010
- Messages
- 23
When I try to run the macro containing the following code an "Application-defined or object-defined error" is generated
Code:
If Not IsNumeric(Application.WorksheetFunction.Mode(stock1)) Then
stock1Mode = "No Mode"
ElseIf IsNumeric(Application.WorksheetFunction.Mode(stock1)) Then
stock1Mode = Application.WorksheetFunction.Mode(stock1)
End If
If you look at the code you will see that I am trying to have the macro return a string "No Mode" when the array on which I am using the mode function does not contain any numerical elements which are the same, but when there are two or more identical numerical elements, the macro should return the mode of the array.
When I step through the code the error is generated on the second line. Apparently it doesn't like "stock1Mode = "No Mode"... Any suggestions would be greatly appreciated because I am at my wits end!
Code:
If Not IsNumeric(Application.WorksheetFunction.Mode(stock1)) Then
stock1Mode = "No Mode"
ElseIf IsNumeric(Application.WorksheetFunction.Mode(stock1)) Then
stock1Mode = Application.WorksheetFunction.Mode(stock1)
End If
If you look at the code you will see that I am trying to have the macro return a string "No Mode" when the array on which I am using the mode function does not contain any numerical elements which are the same, but when there are two or more identical numerical elements, the macro should return the mode of the array.
When I step through the code the error is generated on the second line. Apparently it doesn't like "stock1Mode = "No Mode"... Any suggestions would be greatly appreciated because I am at my wits end!