+ Reply to Thread
Results 1 to 6 of 6

Dynamic Ranges - Create Using VBA as looping through Sheets

  1. #1
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Dynamic Ranges - Create Using VBA as looping through Sheets

    Hello,

    I’m attempting to grasp the concepts of working with arrays.
    • Is it possible to loop through a series of worksheets containing the same types of data
    • Select all the data on each sheet
    • Declare the data as a range dynamically ( if this is necessary)
    • Load that range into an array (nRows, 5Col)
    • And then perform actions based upon items in that array?

    Please Login or Register  to view this content.
    I’ve attached a workbook with sample data and the code that I’ve managed to cobble together at this point.
    It doesn't loop through the worksheets nor dynamically create the data ranges.

    Thanks for your assistance.
    Mark
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Dynamic Ranges - Create Using VBA as looping through Sheets

    I wrote the attached code for another thread. It gives you some direction. I have put comment on each line. No every single line may be relevant to your case, it is just a guide.
    Attached Files Attached Files

  3. #3
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Thumbs up Re: Dynamic Ranges - Create Using VBA as looping through Sheets

    Thanks a lot AB.
    It's an elegant piece of code.

    I had a problem with a "Subscript out of range" on this line.
    I commented out that particular "If" statement and the code ran fine.
    Please Login or Register  to view this content.
    I was wondering what the intention was for this bit of code?
    When I changed the number from 7 to 5, I received the value of the date in column five.
    The problem was, it wouldn't output at all to the Master Worksheet.

    I'd be interested in understanding the mechanics of this.

    Thanks again.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Dynamic Ranges - Create Using VBA as looping through Sheets

    Please Login or Register  to view this content.
    Simply testing if column G is nil. It is one of the condition for that particular task.

    The reason forgetting the error is this line.

    Please Login or Register  to view this content.
    The max column loop the X array can take is 5, which is E. If you change it to G, you would not get an error.

  5. #5
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Dynamic Ranges - Create Using VBA as looping through Sheets

    I was wondering what the intention was for this bit of code?

    The person who asked the question wants to copy all columns if column E is blank. So, the condition is "If statement". Not all rows in column E are blank.

  6. #6
    Forum Contributor
    Join Date
    07-11-2009
    Location
    NYC,USA
    MS-Off Ver
    Excel 2007
    Posts
    135

    Re: Dynamic Ranges - Create Using VBA as looping through Sheets

    Thanks for the explanation.
    I didn't think to look back in the code to find the problem.
    A very useful bit of information.

    Thanks again.

+ 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] To use name manager or create dynamic ranges in VBA
    By chrisjames25 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-19-2013, 03:37 PM
  2. How to create dynamic ranges, better alternative to OFFSET
    By JamesGoulding85 in forum Excel General
    Replies: 2
    Last Post: 06-04-2013, 03:27 PM
  3. [SOLVED] Create Multiple Dynamic Named Ranges with a Macro
    By bennank in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2012, 12:55 PM
  4. Looping through dynamic ranges from multiple worksheets
    By TechWrangler in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-08-2006, 03:20 PM
  5. [SOLVED] Looping with Hidden and Protected Sheets/Ranges
    By ExcelMonkey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-08-2005, 02:07 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