How to **Read range** for part of Excel table, whose table size you don't know?

I have an excel sheet, with a table on the left, and some other information (not a table) on the right.
The table on the left uses the column A through column E, and this won’t change.
But the number of rows on the table varies every month, and I need to retrieve this table data only, using Read Range.

how could I do this? I cannot really specify the range, because I dont know how many rows will be there in the table. All I know is the column uses A through E.

But if I just read the whole page, the range can be wrong because we also don’t know how many rows some other information on the right side of the sheet are using.

Hi @tomato25

You can mention the range like this

“A:+dt.rows.count.toString+”

Thanks
Ashwin.S

Hi @tomato25

Assuming the data does not overlap columns, could you use a range A:E

We don’t know the row count.

When I chose the range as “A:E” and ran the program, it froze…

Do you have a maximum for the number of rows you could be trying to read?

Hi @tomato25

Use A1:E300

Thanks
Ashwin.S

1 Like

We don’t know how many rows will be there, and I prefer not hard-coding the row number.

What I was thinking was, Maybe read the whole sheet using Read Range by not specifying the range at all, and then somehow remove all data existing after column E, from the data table. Is this possible at all? I am not sure how to approach this method though…
If the whole page was a table, I could "Filter Data Table* by column names, and get only columns I want. But this sheet has both a table and something else…

That is good option

Filter the columns you want and get the data and store it in a datatable and then check the count

Thanks
Ashwin.S

If this is an Excel table, you can easily use “Get Table Range” to find the range of your table, then use “Read Range” and read the range that you just found.

Capture1

@tomato25 There is no harm in getting too many columns. You should simply leave the range property blank so it grabs the entire sheet to a datatable. Then, you can either ignore it (if you aren’t pasting the datatable back to excel and are only reading values from it), or if you want to remove extra columns and they’ll always be after column E, then you can iterate through and remove all columns if column.ordinal > 4 (ordinal 0 = A, ordinal 4 = E)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.