"IF" activity and excel

Hello,
I am working on an automation that pulls information from an excel file and fills out fields in a website. One of the activities that needs to be completed is selecting the rank of the project using a drop down field. In the excel file, there is a box that can be checked to signify the rank of the project. If the box is checked, it is one rank, and if it is not checked, it is the other. How can I go about performing this operation using an If activity. I tried using natural speech to fill out the VB expression, but Autopilot was unable to generate an expression to kickstart the activity.
Any help that can be provided would be greatly appreciated.
Thank you very much.

@craig.mcdonald

This is doable using VBA macro code.

1 Like

@craig.mcdonald

When you read the excel file how are you getting the value in datatable..depending on that we can use if condition

Cheers

1 Like

Hi @craig.mcdonald

Since you’re reading from Excel, the checkbox value should be interpreted as a Boolean in datatable. Check what is being returned , it will be either “True/False” or 1/0.

Accordingly you can put condition and proceed . For eg : CurrentRow(“Rank”).ToString.Equals(“Yes”)
CurrentRow(“Rank”).ToString = “1”

1 Like

Hi @craig.mcdonald

If you have any influence on the Excel sheet itself then you could consider naming the cells.
This makes it easy to extract their values based on this name.

Regards
Soren

1 Like

Hi @craig.mcdonald

When you read the Excel row, the checkbox value comes as True/False (or Yes/No). Just use an If condition on that value. If it’s checked, select one rank from the dropdown; if it’s not checked, select the other. Simple If + Select Item/Click inside the loop works better here than using Autopilot.

1 Like

The bot can’t literally can’t see the real values for Checked or Unchecked cells in excel.

Giving prompt to Autopilot to directly get the value of checked or unchecked cell will not give accurate response. Instead you can try asking: “Generate a VB.net expression to check if a DataRow column named ‘Rank’ is True.”

How to get the exact boolean value of checkbox:
Mostly the Excel sheets link a checkbox to a specific cell (like one hidden behind the box).
1. Find the link: Right-click the checkbox > Format Control > Control tab. Look at the Cell link field (e.g., cell A1).
2. The Result: When the box is checked, that cell will literally say TRUE; if unchecked, it says FALSE.
3. Pro Tip: If there’s no linked cell, “Read Range” won’t work. You’d have to use messy VBA code, so it’s much better to just link the cell yourself if you can.

How to get the value in UiPath:
Once you’ve used a Read Range activity to get your data into a DataTable, use a For Each Row loop with this logic:
- The “If” Condition: CurrentRow(“YourColumnName”).ToString.ToUpper.Equals(“TRUE”) (Using .ToUpper makes sure it works whether Excel says “True”, “true”, or “TRUE”.)
- The Action: Then: If true, use Select Item for “Rank A.”
- Else: If false, use Select Item for “Rank B.”

Suggestion: If you have a choice, tell the team to use a simple dropdown menu (Data Validation) instead of checkboxes. It’s way more reliable for RPA.

1 Like