Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default clearing an array

If I am interpretting your problem correctly then declare the array as
Variant then the min function ignores any empty elements except when all are
empty min returns zero. (I think you have established that.)

Therefore test for min returning zero and if so assume all are empty or zero
else run min function to return a number other than zero. Following example
populates just some elements of an array declared as variant and you will see
that min returns the correct minimum value of 3.

Sub MinFctnWithArray()

Dim MyArray() As Variant
Dim i

ReDim MyArray(1 To 10)

For i = 3 To 10 Step 2
MyArray(i) = i
Next i

For i = 1 To 10
MsgBox "Array element " & i & " = " & MyArray(i)
Next i

If WorksheetFunction.Min(MyArray()) = 0 Then
MsgBox "All elements in MyArray are empty or zero."
Else
MsgBox "Min value in array is " & WorksheetFunction.Min(MyArray())
End If

End Sub


--
Regards,

OssieMac


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
clearing an array mark Excel Programming 5 June 25th 07 11:23 PM
Clearing Array Contents Ken Hudson Excel Programming 1 May 5th 07 07:35 PM
Array for clearing checkboxes Richard Excel Programming 6 August 12th 05 08:37 AM
clearing array contents mark Excel Programming 15 June 8th 05 03:51 PM
vba clearing out values stored in array chick-racer[_44_] Excel Programming 2 December 1st 03 09:05 PM


All times are GMT +1. The time now is 10:03 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"