How to use VB Script to find Row Count?


I want to get the row count of the data table. Data is huge, more than 1 lakh rows. How can I use VB Script activity for this?

Thanks in advance!


Use this in a assign activity to get the row count

int_rowcount = datatable.Rows.Count

Where int_rowcount is a variable of type int32

Cheers @Sanket_Agarwal

Hello @Palaniyappan

Thank you for the response. I tried this but as since the size of the data is huge, it is taking forever to give response.

Thanks and regards,
Sanket Agarwal

Hi @Sanket_Agarwal ,

Most probably it is due to the way the File is being read. I don’t suppose the Rows.Count method would be delayed in providing a response.

Could you let us know How are you Reading the large data ?

Hello @supermanPunch

Thank you for your response!
Yes I also think that Read Range activity is taking time rather than Row.Count
Is there any way to get excel into data table type ? can you suggest me some way out of it?

Thanks and Regards,
Sanket Agarwal

@Sanket_Agarwal ,

Have you tried the Below Component ?

Hi @Sanket_Agarwal

Can you please convert the copy of excel file into CSV and then try getting the row count?
It will give quicker results through csv.

Try this and let me know.

Hello @supermanPunch

Your Solution Worked. Thank you so much. It was a big pain point.

Solution in simple words: first we have to install a package named UiPathTeam.XLExcel
Then use Read Range XL Excel, then use DataTable.Rows.Count.ToString.

1 Like

Hello @Aparna_Chaudhari

Thank you for your response.
The run time with Xl Excel scope is 55 sec. I think that even if I’ll convert it into csv, run time will be more than this. But I’ll try it next time.

Thanks and Regards,
Sanket Agarwal

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