I have an excel file that contains 2 tables on a single worksheet. The table1 always has headers starting in row 1 and contains a variable amount of rows. Because of this, table2’s headers begin at a different row in each excel file.
Table1’s structure looks like this in Column A:
Column1
123556612
672437742
123785246
[random # of blank rows]
[random string]
[random # of blank rows]
Column1:
672437742
672437742
I’d like to put these in two separate datatables. What is the best way to go about this?
I can think of 2 ways, but not sure if either are all that great. I’m leaning towards the 2nd way as that seems like it’d be faster & more straightforward. Please let me know if anyone has some suggestions on how to improve this. Table1 generally has only 15-30 rows whereas table2 will have anywhere from 1k-20k rows (estimated). Note that only steps 3 & 5 differ between the two.
1st way:
- Read entire sheet with read range activity and put in tempDatatable
- Get the End index of the first table by finding the first blank row & subtracting 1
- Copy the first rows until the end index of table 1 using a loop & put in datatable1
- Find the start index of the 2nd table by searching for “Column1” within Column A.
- Copy all rows starting from the start index of table2 and put in datatable2
2nd way:
- Read entire sheet with read range activity and put in tempDatatable
- Get the End index of the first table by finding the first blank row & subtracting 1
- Use read range activity and input “A1:S” + end index [// fixed number of columns are used]
- Find the start index of the 2nd table by searching for “Column1” within Column A.
- Use read range activity and input “A” + start index + “:S” + tempDatatable.count.tostring