Finding Last Empty Row from Specific Columns in a Data Table

Hello Forum, hope y´all having a great day.

This topic is divided in two question, where any of the two can solve my problem.

First question, as the title quotes… I have a data table with lets say five columns. The first three columns have the same amount of data, but the last two does not. My goal is to be able to find the index number of the first empty row from the last two columns, so I can retrieve that index and input data right from the correct row.

I know I could achieve this result by iterating through the data table, but I´m thinking they should be a expression that can also find it.

Second question
I would like to read a range from only the columns in “E” through “G” so in my Read range activity I want to state that I want to read freely but only through this to columns letter, How can I achieve this? Maybe I know the index to start from the letter “E” like 2 but the range for G for me y dynamic and I can´t input to the range property something like this “E2 : G” as far as I know. So How could I make this specific but dynamic enough?

Thank you very much for yours attention. I´ll be waiting for response.

@Luis_Fernando

  1. For this you can try something like this dt.Rows.IndexOf(dt.AsEnumerable.Where(function(x) string.IsNullOrEmpty(x(3).ToString) OrElse string.IsNullOrEmpty(x(4).ToString))(0)) this gives the row index
  2. Try with “E:G” or after reading just use filter datatable and give 4 5 6 as the columns in filter.

Hope this helps.

Cheers

Hello Dear Friend @Anil_G

Thank you for your soon feedback!

Quik questions

In the expression “3” and “4” are the column index right?

That will be all, I´ll try them right away.

1 Like

@Luis_Fernando

Yes its the index…you can swap with column names as well if needed

Cheers

1 Like

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