Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
Type Mismatch with UBound and arrays
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="DG, post: 6429921"] I can't see what is wrong with this code In the Function MaxOfArray I get a type mismatch on the line "For i = 1 To UBound(TheArray). I think it has something to do with Set OrderDateArray = Sheets("Sheet2").Range("A2", Range("A65536").End(xlUp)) , which has only 36 rows. Even if I put k = UBound(OrderDateArray) in the main sub I get the error. I know this must be something simple that I can't see. Sub Forcast_Prod() Dim OrderDateArray As Variant Set OrderDateArray = Sheets("Sheet2").Range("A2", Range("A65536").End(xlUp)) Max_Date = MaxOfArray(OrderDateArray) End Sub Function MaxOfArray(ByRef TheArray As Variant) As Integer ' This function gives the max value of an integer array without sorting the array Dim i As Integer Dim MaxIntIndex As Integer MaxIntIndex = 0 For i = 1 To UBound(TheArray) If TheArray(i) > TheArray(MaxIntIndex) Then MaxIntIndex = i End If Next 'index of max value is MaxValOfArray MaxOfArray = TheArray(MaxIntIndex) End Function [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
Type Mismatch with UBound and arrays
Top