+ Reply to Thread
Results 1 to 3 of 3

Dynamic Range in For Loop

  1. #1
    Forum Contributor
    Join Date
    12-18-2011
    Location
    long island
    MS-Off Ver
    365
    Posts
    236

    Dynamic Range in For Loop

    Hello,

    I have the below code:
    Please Login or Register  to view this content.
    This code works fine in the set ranges of T4:T30, W4:W30, and X4:X30 but now I would like to make these ranges dynamic.
    For example, based on the Date in D1, find that date in Row 3, and work in that area. Would this be possible using Offset?
    Attached Files Attached Files

  2. #2
    Forum Expert Crooza's Avatar
    Join Date
    10-19-2013
    Location
    Hunter Valley, Australia
    MS-Off Ver
    Excel 2003 /7/10
    Posts
    2,082

    Re: Dynamic Range in For Loop

    Hi, Not sure I can get your macro working as I'm not sure exactly what it does BUT as far as converting the fixed references to columns to variable references maybe try this. I set variables for the MOH value in the same month, the MOH column in the prior month and this column value for the chosen month. I assumed column "i" stays fixed and the others move relative to the chosen date. The dates were 2023 but your field in D1 was 2022 so I changed that and it at least seems to make amendments to the correct columns.

    Please Login or Register  to view this content.
    Happy with my advice? Click on the * reputation button below

  3. #3
    Forum Expert BadlySpelledBuoy's Avatar
    Join Date
    06-14-2013
    Location
    East Sussex, UK
    MS-Off Ver
    365
    Posts
    7,468

    Re: Dynamic Range in For Loop

    Similar approach to Crooza's one above

    Please Login or Register  to view this content.
    Note, it should really have error trapping because if the date in D1 does not appear in row 3 (as per your example file) then it will fall over.

    BSB

+ 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. [SOLVED] Setting Dynamic Loop Range
    By radddogg in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-12-2017, 12:13 PM
  2. Filling Comboboxes with a loop from a dynamic range
    By dougman824 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-13-2017, 10:03 AM
  3. [SOLVED] Loop through a dynamic range.
    By Sluggoslabang in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 09-06-2016, 02:41 PM
  4. [SOLVED] Dynamic range in a loop
    By trailonu in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-30-2015, 07:22 PM
  5. [SOLVED] Merge Cells in Dynamic Range using For loop
    By crazymazy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-01-2013, 11:33 AM
  6. VBA Plot Multiple Charts Using Loop Through Dynamic Range
    By sanjeevpandey in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-30-2013, 07:38 AM
  7. Loop with dynamic range
    By mthomas in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 12-22-2011, 10:35 PM

Tags for this Thread

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