the #VALUE! error (A value used in the formula is of the wrong data type).
I'm not sure I would assign this kind of specific meaning to a spreadsheet #VALUE error. In my experience with UDF's, the #VALUE error really means "I came across some kind of untrapped runtime error that I could not resolve so I will put #VALUE here instead". This could be a data type mismatch error, or it could be a syntax error, or it could be an untrapped divide by 0 error or whatever.
You indicate that removing the counter=counter+1 statement "resolves" the error. Since all counter is doing is specifying what element from table(i,j) to return, I would guess that counter becomes a value that is incompatible with the table() array (probably why Norie wants to see how table() is defined and filled). I think the next thing I would do would be to add a stop statement (probably right before counter is initialized), then step through the loop -- paying careful attention to what counter, table, arr, entry, and any other variables are doing using the locals and watch windows.
Bookmarks