Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 group that also vary in length (rows). The groups are separated by 2 blan rows and the data in each group is contiguous. How can I select these groups and process them when I don't always kno how many there are or how long they are. Thanks -- Brian Matlac ----------------------------------------------------------------------- Brian Matlack's Profile: http://www.excelforum.com/member.php...nfo&userid=350 View this thread: http://www.excelforum.com/showthread.php?threadid=47828 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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" wrote in message news:Brian.Matlack.1x9hud_1129914323.4604@excelfor um-nospam.com... 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how to put a loop in a macro? | New Users to Excel | |||
macro loop | Excel Discussion (Misc queries) | |||
macro loop | Excel Programming | |||
Help With loop macro?? | Excel Programming | |||
Using for loop in a macro | Excel Programming |