How to get the last row count of specified column?

Hi UiPath,

I need help in automating my task,

Is there a way to count the last row of a specified column only?

example below:

image

Column B contains blank data I want to get its row number

thanks!

@Alvin_Apostol2

  1. Use Read Range activity to read the data from Excel file and it will give output as DataTable. Let’s say dtInput.

  2. And then try below expression to find the row count of Status column.

        rowCount = dtInput.DefaultView.ToTable(False,"Status").Rows.Count
1 Like

HI @Alvin_Apostol2

You can try as @lakshman suggested and also you can try this methods

Method 1

  • Use Read Range and store in a variable
  • For each row in datatable and loop through the column
    • Inside keep if activity and give condition as Row(“Status”).Equals("")
    • Then you can process your task
    • Else keep empty it will go to next row

Method 2

  • Use Read Range and store in a variable
  • Use Lookup Datatable and give lookup value as “” in column status and get the row index from there.
  • Do your task and write your statuses from “B”+(Rowindex +2).ToString

Method 3

  • This is similar as above but use Lookuprange activity.
  • Give your value as “” and in range area you need to provide “B1:B”+dt.rows.count.tostring and store in the variable there (it will provide the first found values cell address like B3).
  • Do your task and write your statuses from range lookuprange variable .

Regards
Gokul

3 Likes

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