#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to put a loop in a macro? Khoshravan New Users to Excel 4 May 14th 06 01:22 PM
macro loop Helen Excel Discussion (Misc queries) 7 January 12th 05 02:42 PM
macro loop stockers Excel Programming 1 October 6th 04 03:07 PM
Help With loop macro?? pauluk[_28_] Excel Programming 1 April 16th 04 01:58 AM
Using for loop in a macro dipti.agrawal Excel Programming 2 January 16th 04 06:18 PM


All times are GMT +1. The time now is 04:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"