View Single Post
  #9   Report Post  
Posted to microsoft.public.excel.programming
scattered[_5_] scattered[_5_] is offline
external usenet poster
 
Posts: 4
Default Find Combinations

On Tuesday, June 30, 2015 at 6:20:07 AM UTC-4, Bruno Campanini wrote:
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?


On Tuesday, June 30, 2015 at 6:20:07 AM UTC-4, Bruno Campanini wrote:
(snip)


Out of curiosity, what is the motivation for this problem?

I have some ideas about how to modify the code so that it will keep track of the rows where each combination appears (and still run in a couple of seconds), but the resulting code would be too long to easily post. Perhaps we can continue this conversation via e-mail. Feel free to send me one (prefix "re" to my nickname and add the usual gmail suffix)

I didn't realize you could specify the variant subtype when redimensioning the variable. That is useful to know. Thanks.

I am from the US, near Pittsburgh. Professionally I do math and computer science (mostly math) which is why your post raised my interest.