View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Bruno Campanini[_2_] Bruno Campanini[_2_] is offline
external usenet poster
 
Posts: 74
Default Find Combinations

scattered laid this down on his screen :

Glad you could use it. I had fun writing it.

Well, I'll have much to do in adapting your code to my needs...
For each matches() I need to get the row of myrange where it appairs.
I think it will take a lot of time compared with simply get how
many matches() in the full myrange.
I'll keep you informed.

I have a strong preference for using variants to pass arrays to or from
functions/subs.

I normally do the very same thing.

For one thing -- it is somewhat idiomatic if you consider
the way built-in functions like Split() and Join() accept or return variant
arrays. For another thing -- it is easier to use variant arrays to transfer
data between VBA and the spreadsheet. In my code, I initially didn't include
that initialization loop for matches. But when I ran it matches(6) was Empty
rather than 0, and the way I was building up the report string in the test
code caused this empty value to be converted into the empty string rather
than to 0. This caused the last line to look like

Combos of size 6 =

with nothing to the right of the equals sign. Hence the explicit
initialization to 0.

If you simply state
ReDim matches(1 To n)
you get matches() "full" of empty string

but if you state
ReDim matches(1 To n) As Integer or As Long or As Currency
you get matches() "full" of 0

Ciao
Bruno

PS
I'm from Italy.
Where are you from?