+ Reply to Thread
Results 1 to 2 of 2

Loop Macro

  1. #1
    Forum Contributor
    Join Date
    12-04-2003
    Location
    Burrton, Kansas USA
    MS-Off Ver
    2003
    Posts
    162

    Loop Macro

    Hi!
    I don't yet understand loop macros but I'd like to.
    I am importing a text file that is a variable number of data groups that also vary in length (rows). The groups are separated by 2 blank rows and the data in each group is contiguous.
    How can I select these groups and process them when I don't always know how many there are or how long they are.
    Thanks!

  2. #2
    Bernie Deitrick
    Guest

    Re: Loop Macro

    Brian,

    You need to loop through the areas collections of the filled cells. See the macro below for an
    example, which assumes that your filled cells are constants.

    HTH,
    Bernie
    MS Excel MVP

    Sub Macro2()
    Dim myCell As Range
    Dim myArea As Range
    Dim myData As Range

    Set myData = Cells.SpecialCells(xlCellTypeConstants, 23)

    For Each myArea In myData.Areas
    MsgBox myArea.Address & " has " & myArea.Cells.Count & " cells."
    'Process areas here
    For Each myCell In myArea.Cells
    'use this inner loop to process through the cells
    Next myCell
    Next myArea
    End Sub


    "Brian Matlack" <[email protected]> wrote in message
    news:[email protected]...
    >
    > Hi!
    > I don't yet understand loop macros but I'd like to.
    > I am importing a text file that is a variable number of data groups
    > that also vary in length (rows). The groups are separated by 2 blank
    > rows and the data in each group is contiguous.
    > How can I select these groups and process them when I don't always know
    > how many there are or how long they are.
    > Thanks!
    >
    >
    > --
    > Brian Matlack
    > ------------------------------------------------------------------------
    > Brian Matlack's Profile: http://www.excelforum.com/member.php...fo&userid=3508
    > View this thread: http://www.excelforum.com/showthread...hreadid=478288
    >




+ 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