+ Reply to Thread
Results 1 to 5 of 5

Setting Dynamic Loop Range

  1. #1
    Forum Contributor
    Join Date
    10-25-2011
    Location
    Preston, England
    MS-Off Ver
    Excel 2016
    Posts
    136

    Setting Dynamic Loop Range

    Hi,

    I'm hoping you can help me identify where I'm going wrong with this loop. I am allocating stock to demand based on a catalogue number in one column and a contract in another.

    This is my code. Don't get me wrong, it works, but it's very slow because of the number of iterations. I'm hoping to dramatically reduce this by doing something with the range.

    Please Login or Register  to view this content.
    Cheers Radddogg
    Last edited by radddogg; 09-08-2017 at 06:37 AM. Reason: added in line that might affect speed

  2. #2
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Setting Dynamic Loop Range

    Why not use Application.Match to identify rownumber of s on sheets Supply instead of looping every value in Column C ?
    Once you found the record you can perform your other tests and do the rest of your stuff.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  3. #3
    Forum Contributor
    Join Date
    10-25-2011
    Location
    Preston, England
    MS-Off Ver
    Excel 2016
    Posts
    136

    Re: Setting Dynamic Loop Range

    Quote Originally Posted by bakerman2 View Post
    Why not use Application.Match to identify rownumber of s on sheets Supply instead of looping every value in Column C ?
    Once you found the record you can perform your other tests and do the rest of your stuff.
    How would I implement that? There could be 20 demands for that part and 20 inventory. Match would find me the first record, how would I move to the next?

    One thing I thought was setting the "sRng" by matching d.value but again I can't think how to set it to all matching cells without using another loop to test the cell value.

  4. #4
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,908

    Re: Setting Dynamic Loop Range

    Best to post example file so we have something to play with.

  5. #5
    Forum Contributor
    Join Date
    10-25-2011
    Location
    Preston, England
    MS-Off Ver
    Excel 2016
    Posts
    136

    Re: Setting Dynamic Loop Range

    For anyone interested this is how I got it to only look at matching values
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 15
    Last Post: 09-10-2013, 05:31 AM
  2. Offset - Setting a dynamic range
    By Krugas in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-02-2013, 02:18 PM
  3. Setting a dynamic Named range
    By hond in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-14-2012, 09:57 AM
  4. Setting Dynamic Range
    By Mike_e in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-03-2012, 09:51 AM
  5. Dynamic range setting
    By KeithO in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-22-2009, 02:15 PM
  6. Setting a dynamic range for a chart
    By dusen in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 08-28-2008, 04:12 AM
  7. Setting dynamic range in a formula
    By Phillycheese5 in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 06-10-2005, 02:58 PM

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