I think just change this line so that it includes the row with the distribution amounts (you had B17):
The code now runs, although I haven't checked that it gives the right answer!![]()
Set rngDistr = Range("B16:K22")
I think just change this line so that it includes the row with the distribution amounts (you had B17):
The code now runs, although I haven't checked that it gives the right answer!![]()
Set rngDistr = Range("B16:K22")
thanks a lot stephen thats some excellent coding
Thank you, my pleasure.
Hi Stephen R,
Ive just tried to put it into a much much larger sheet of data and im getting the match problem again! - Ive attached an example of the scaled up version
Ive tried formats of the numbers, double checking the matrix ranges but still no go!
Is there any limitation to the number of columns?
Thanks
Not sure, it falls over at the match line, although it works if you use the formulae in the worksheet. Not time now, perhaps somebody clever will have a bright idea.
![]()
nMinD = wf.Index(rngDistr, 1, 1 + wf.Match(nMin, rngDistance.Rows(r), 0))
Hi ive solved it, the numbers for the distances must be at least 1.
This has thrown up another problem now of double distribution! Ill post more if i cant fix it.
Thanks
Actually, I made it work by changing one of the declaration statements, I'm mystified as to why it should make a difference, but use
at the start rather than![]()
Dim nMin
Btw, your second range is one column wider than your first - is that right?![]()
Dim nMin As Long
EDIT: also, if you add the constraint that the distribution amounts must be positive it doesn't work.
Last edited by StephenR; 11-13-2008 at 07:33 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks