Is VBA limited to sorting certain number of array values?

simurq

Board Regular
Joined
Nov 11, 2011
Messages
73
I have a set of one-dimensional double arrays each containing thousands of members (geographic coordinates). Eg: Latitude = Array(20.356,22.369,23.568...) as Double || Longitude = Array(120.356,122.369,123.568...) as Double. When I loop through each array with WorksheetFunction.Min() / WorksheetFunction.Max() or even Application.Min() / Application.Max() to get min/max values to draw a boundary box, the results are wrong - a simple copy/paste of array values into columns A and B and MIN{A}/MAX{A} on Excel sheet (no VBA) gives completely different min/max values.

So, I wonder if VBA is limited to sorting a certain number of array values to get min/max values when the above functions are applied?!

Thanks!
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
1. Both
WorksheetFunction.Min
() and
Application.Min()
represent the same:
Application.
WorksheetFunction.
Min()

2. These functions ...Min() and ...Max() are limited.
 
Upvote 0
Jan, thanks for your prompt reply!!! I have a definite, albeit short, answer after a week of complete craziness trying to understand the problem... :)

Can you please elaborate on this or direct me to a source where I can learn more about the limits of arrays (my search hasn't returned any reliable source of info so far, even MS VBA Reference)? Thanks again!!!
 
Last edited:
Upvote 0
I never use max and min function in vba if I am looping through a range; I would calculate as you go: this code find the minumum value in column A
Code:
Sub test()
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
inarr = Range(Cells(1, 1), Cells(lastrow, 1))
temp = 9.99999999999999E+307


For i = 1 To lastrow
 If inarr(i, 1) < temp Then
  temp = inarr(i, 1)
 End If
Next i
MsgBox (temp)


End Sub
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,184
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top