LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default Excel2000: Need help on UDF (working with arrays)

Thanks! I'll give it a try next week.


Arvi Laanemets


"Dick Kusleika" wrote in message
...
Arvi Laanemets wrote:
Hi

I'm trying to write an UDF which is an enchanced NETWORKDAYS
function, with syntax:
ENCHWORKDAYS(StartDate,EndDate,[Holidays],[Weekends])

As both optional parameters can be cell range references, or arrays,
or single values, then I decided to convert them to arrays, and do all
calculations with arrays later.

I haven't used arrays in VBA before. I have used them in FoxPro,
where is a lot of various functions and commands for working with
arrays - compared with this in VBA help I did find next to nothing
about them. So maybe someone explains, how to:
1) sort array elements;


Here's how I do it
http://www.dicks-blog.com/archives/2...ing-listboxes/

2) compact the array (remove elements);


I don't think there's an elegant, built-in way to do that. You can round
trip through a collection to filter out uniques, but since you're moving

it
to H() anyway, I think I would just take the sorted array and

For i = LBound(Holidays) to UBound(Holidays) - 1
If Holidays(i) < Holidays(i+1) Then
Redim Preserve H(0 to j)
H(j) = Holidays(i)
j=j+1
End If
Next i

Redim Preserve H(0 to j)
H(j) = Holidays(UBound(Holidays))

Now H() should be a sorted, unique array from Holidays(). (Although I

didn't
test, it's just conceptual).

3) count elements in array.


lCountElem = UBound(H) - LBound(H) + 1

4) Can array contain an empty (null) value?


Yes, you can use a statement like H(0)=Null.


--
Dick Kusleika
Excel MVP
Daily Dose of Excel
www.dicks-blog.com




 
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
Working with arrays as arguments HB Excel Worksheet Functions 6 September 30th 09 02:48 PM
SUMPRODUCT with 3 arrays not working Kierano Excel Worksheet Functions 1 October 16th 06 03:37 PM
Working with Arrays Judy Excel Worksheet Functions 1 January 11th 06 12:22 AM
Excel2000 A working formula has {braces} which disappear. Why? SpudHutton Excel Worksheet Functions 3 April 22nd 05 01:30 PM
working on 2 different worksheets....arrays? monika Excel Programming 6 February 10th 04 11:40 AM


All times are GMT +1. The time now is 09:01 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"