Read cells in row until empty

I have data in Excel that I would like to count dynamically before processing it :

I need to count the filled cells on row number 7 starting from I7 dynamically, could be less than what’s shown on the picture or could be more, and stop until blank cell found. The data after is not important.

And then iterate through rows using the counter we got from the step before.

I could not apply the solution from this post :

I have this error :

Have a check on following alternate

Read Range with an offset to A7 - dtDataMain
it will read in dynamically the datablock and the Column headers are already set

this requirement needs some more detail specification on

  • for each row or only first Excelrow 8 in Picture
  • subsequent non-blanks count or all non-blank counts from I to end

Can you elaborate how can I apply this step?

I would like to count the filled cells starting from “I7” horizontally to the right, it could go to alphabetical columns like “AA” and the counter would stop at first blank cell encountered. TEST1,2,3 do not need to be counted in the process.

I only need to do this step for Row 7, and extract a counter from it so I can work with it afterwards for the rest of the data below.

About you validation message kindly note:
Row(Col.toString).toString is needed VB.Net
Row/col was swapped
If C# is in use then try
Row[Col.ToString()].ToString();

Same error message…

is C# in use?

Different error message this time :

Is there any other way to count the filled columns?
With a datatable columns count or something else ?

we recommend:

  • let not open / unanswered our questions e.g is C# the selected Programming Languague
  • configure properly the activties - check if the typeargument of the first for each activity is set to DataRow
  • check if the typeargument of the second for each activity is set to DataColumn

Kindly note also the for each row activity

is better to focus on Busines case, requirements definition first then do the implementation. When something is not working on the first shot then check the root cause. But always do the modeling carefully.

1 Like

Okay, so this project is using C#

And i configured both of the for each activity to DataRow and DataColumn, they were set previously to Object.

And i’m using the expression Row[Col.ToString()].ToString(); in the Write Line activity.

And it appears to be working properly.

Thank you @ppr

Perfect :+1: Happy automation

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