+ Reply to Thread
Results 1 to 20 of 20

Code loop through two tables checking and altering

Hybrid View

  1. #1
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    I think just change this line so that it includes the row with the distribution amounts (you had B17):
    Set rngDistr = Range("B16:K22")
    The code now runs, although I haven't checked that it gives the right answer!

  2. #2
    Registered User
    Join Date
    08-30-2008
    Location
    London
    Posts
    35
    thanks a lot stephen thats some excellent coding

  3. #3
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    Thank you, my pleasure.

  4. #4
    Registered User
    Join Date
    08-30-2008
    Location
    London
    Posts
    35
    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
    Attached Files Attached Files

  5. #5
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    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))

  6. #6
    Registered User
    Join Date
    08-30-2008
    Location
    London
    Posts
    35
    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

  7. #7
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606
    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
    Dim nMin
    at the start rather than
    Dim nMin As Long
    Btw, your second range is one column wider than your first - is that right?

    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.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1