Results 1 to 6 of 6

Dynamic Ranges - Create Using VBA as looping through Sheets

Threaded View

  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?

    Sub TestArray()
    
    Dim SheetData As Variant
    Dim lngRow As Long
    Dim lngCol As Long
    Dim SrcRng As Range
    
    SheetData = ThisWorkbook.Names("SrcRng").RefersToRange
        For lngRow = LBound(SheetData) To UBound(SheetData)
        For lngCol = LBound(SheetData, 2) To UBound(SheetData, 2)
        
     Debug.Print "Item ("; lngRow; ","; lngCol; ")", SheetData(lngRow, lngCol)
        
        Next
        Next
    Debug.Print
    
    End Sub
    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

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