tags:

views:

38

answers:

1

I have a sheet in which I'm entering values in cell from two different tables.First table has 3 fields so sheet1.range from A1 to c23 gets filled with this table values.Now the second table has two fields and I fill Sheet1 from A25 till B37.

Now each of the table gives me column headings at A1,B1,C1 for the first table and A25,B25 for the second table.So I want to traverse through this entries but when I encounter table2 entries or more specifically a column heading I should halt and traverse through them for a different process altogether.

The number of rows for either table is not fixed.

+1  A: 

You can process each table row-by-row and use an empty cell in first column as a break criterium. You however have to asume an absolute max of rows or a constant number of tables in your sheet unless you want to search until line 65k .... example:

Sub Test()
Dim MyR As Range, Idx As Integer

    Set MyR = [A1]
    Idx = 1

    Debug.Print "Header 1 = " & MyR(Idx, 1)

    'advance to end of table
    Do While MyR(Idx, 1) <> ""
        Idx = Idx + 1
    Loop

    'advance to next header (could be one or more blank lines)
    Do While MyR(Idx, 1) = ""
        Idx = Idx + 1
    Loop

    Debug.Print "Header 2 = " & MyR(Idx, 1)

    'etc

End Sub

Hope that helps .... good luck - MikeD

MikeD