I am trying to use a if activity in the use ecel file activity studiox

Hi there,

I am trying to use a if activity in use excel file to see if a specific value which is a word contains in the rowcount. However it throws an error saying is not a member of integer.

How to resolve?

@Mark_Rajkumar

May I know what expression are you using?

contains cannot be used on numbers…numbers can be compared usign equals

cheers

I am using if activity inside the use excel activity. I want to see if red is inside a column in the excel. If red exist than i wan to delete the whole row.

@Anil_G fyi

@Mark_Rajkumar

To start with delete rows cannot be used inside for each

instead you can achieve that like this as below using filter and delete visible rows
.Please check the xaml

TextToExcel (2).zip (21.3 KB)

Hope this helps

cheers

Thanks for the sharing. I want use if activity in it, if the text Red contains i should delete otherwise it can skip this search. How to use this?

@Anil_G fyi

Hi @Mark_Rajkumar, if you’re looking for the condition to check if that column value contains ‘Red’, you can use CurrentRow.Item(“Color”).Contains(“Red”) while you loop through the rows in excel.

But I’m not sure about the activities that can help you delete a row as @Anil_G mentioned

@Mark_Rajkumar

Where or how you want to use if activity?

Inside a for loop you cannot use deete …so even if you use if delete is not possible…

If you just want to check then inside for loop use if and add condition with contains

CurrentRow.ByField(“B”).ToString.Contains(“Red”)

Cheers

@Anil_G in this case how do i delete a row using a if activity?

@Mark_Rajkumar

Inside the for each row in excel you cannot use delete row…

If you still want to use loop itself…then read the data into datatable and create a loop on that and add a if condition similarly…then use delete row using the index number from the datatable for loop

Cheers

@Anil_G can u draft down the steps to follow in studiox

@Mark_Rajkumar

It looks like this

(ForIndex - Deleted+ 2).ToString - This is in delete row postion field.

ForIndex is the value fetched from For loop properties

Deleted is a variable created as number with initial value as 0 and when ever a row is deleted value is incremented by one as in excel one row will be less and all rows move one row above

image

Added two because the index starts from 0 and there will be a header in excel which takes one more row …so two

Hope this helps

cheers

@Mark_Rajkumar

Please close this if it is solved…

Cheers