UiPath For Each Row Example |Video upload date:  · Duration: PT5M35S  · Language: EN

Quick guide to using UiPath For Each Row to iterate a DataTable handle data conversions and avoid common errors

Step by step UiPath For Each Row guide for DataRow handling and debugging

If you want your RPA to stop crying when it meets messy spreadsheets then this UiPath tutorial is for you. We will walk through using For Each Row on a DataTable so your automation does real work instead of throwing exceptions and passive aggressive log messages. Expect practical tips about Excel, DataRow access, conversions, debugging and basic error handling with a wink and a shrug.

Prepare the DataTable the sane way

Start with a clean DataTable. Read Range from Excel for real data or Build Data Table for quick tests. A consistent schema keeps DBNull surprises to a minimum and makes parsing less painful. If you can, filter or trim bad rows before looping so your robot does not earn overtime by fixing garbage.

Name things so you can read your workflow later

Use clear names like currentRow for the row variable and prefer column names over indexes for readability. currentRow(0) will work, but currentRow("Email") is less likely to cause a mysterious bug at midnight.

Set up For Each Row and access values like a pro

Add the For Each Row activity and point the DataTable property to your prepared table. Inside the loop read values with expressions such as:

currentRow("Name").ToString()

Or by index when you must:

currentRow(0).ToString()

If you need numbers use safe parsing rather than hope and prayer:

Integer.Parse(currentRow("Age").ToString())
' or safer
Dim age As Integer
Integer.TryParse(currentRow("Age").ToString(), age)

Handle nulls and bad data without panicking

Spreadsheets lie. Check for DBNull up front and provide defaults. A typical pattern looks like this:

Dim price As Decimal
If IsDBNull(currentRow("Price")) Then
  price = 0D
Else
  price = Decimal.Parse(currentRow("Price").ToString())
End If

Wrap fragile parsing in Try Catch when the data really wants to be dramatic. That keeps your automation robust and your inbox mercifully quiet.

Debugging and logging that actually helps

Run with breakpoints and Log Message activities to inspect values during the loop. Use Slow Step to watch the robot act. If something is broken add a message with the offending row index and a sample of values so you can point and laugh at the spreadsheet later.

Useful debug checklist

  • Log the row number and key columns
  • Set breakpoints before conversions
  • Use Try Catch to capture and log parsing failures

Performance tips for big DataTable objects

For large tables filter rows before looping. DataTable.AsEnumerable with LINQ is your friend when you need to preselect rows and reduce processing time. Fetch only columns you need and prefer batch operations when possible to keep your automation fast and polite.

Recap and final sanity checks

This guide covered preparing a DataTable, wiring For Each Row, accessing DataRow values, safe conversions and basic error handling so your UiPath automation is less brittle and more reliable. A tiny bit of defensive coding saves many hours of debugging and a few choice curse words.

Keep these keywords in mind when searching for help or writing documentation: UiPath, For Each Row, DataTable, DataRow, Excel, RPA, Automation, Debugging, Error Handling and UiPath Tutorial.

I know how you can get Azure Certified, Google Cloud Certified and AWS Certified. It's a cool certification exam simulator site called certificationexams.pro. Check it out, and tell them Cameron sent ya!

This is a dedicated watch page for a single video.