Combine more statements in one if statement issue

Is it possible to check 2 values in same IF statment ??

I have an if statment where I check if current row “ID” is same as next row “ID” and upon that result i go true or false…
true = open a website
false = log message = its false.

Now im thinking to check a specifik column have vlaue or not. if it has value then it showed go to next row and if not take that row ID.

ID : Test
2 : ITM123
5 :
9 :
8 :
6 : ITM546
6 :

I tried with somethng like…
dtExcel.Rows(RowCount)(“Test”).Tostring = “” And (dtExcel.Rows(RowCount)(“ID”).Tostring <> (dtExcel.Rows(RowCount+1)(“ID”).Tostring))

It’s not giving right answer…
its telling ID is same on next row where ID is not same on row 5 and row 9. So something is not correct the way i did combinination…

The correct answer is open the web page for ID 5 9 8 and not for 1 and 6 which has vlaue.

Hi @Latif
1)the AND Operator should work with IF . Try understanding the difference between NULL , “” and Nothing and see which fits best in your scenario.
2)You can use a nested if and put 1 if condition inside the previous if condition if option 1 doesn’t work.
Check out the post below, i believe it will directly solve your query.

hi sheten

i figured out that im not getting the value from colum that way its not working…
means this is wrong…
dtExcel.Rows(RowCount)(“Test”).Tostring = “”

how can i get row value checked on a specifik column?

like in the for each loop how can i check that my column Test has a value or not on the specifik row?

can you help @Palaniyappan

dtExcel.Rows(RowCount)(“Test”).Tostring.Equals(“”) And Not dtExcel.Rows(RowCount)(“ID”).Tostring.Equals(dtExcel.Rows(RowCount+1)(“ID”).Tostring)

@Latif - Please check this…

Hi Latif is the issue resolved ?

no it is not resolved yet…
Problem is I’m doing 2 differnt things at same time…

Im checking if my current row and next row is same… which is working fine by this code with in a for each row loop…
dtExcel.Rows(RowCount)(“ID”).Tostring <> (dtExcel.Rows(RowCount+1)(“ID”).Tostring)

but I want to check at the same time that my another column has value or not…
and that code in not working.
may be i should it seprate.

Check this picture tell me how can i go away of so many if statement which in inside the for each row loop…

The first IF where i do count i need to have seprate…
But rest 3 if statements I need to combine… hope I can do that with your help.

I need to put this ** row(“CodeDescription”).ToString.Contains(“Start Vacation”) ** under a way så that when my Excel file do not have the specifik column it ignore the whole IF statment with Then and Else part.

intRowCounter < dtExcelSheetData.Rows.Count-1 THEN
dtExcelSheetData.Rows(intRowCounter)(“SysID-number”).Tostring = “” THEN

My main logic of different steps I want to perform is coming under code…
dtExcelSheetData.Rows(intRowCounter)(“ID-number”).Tostring = dtExcelSheetData.Rows(intRowCounter+1)(“ID-number”).Tostring THEN
And the last code where i check “Code Description” is optional…
row(“CodeDescription”).ToString.Contains(“Start Vacation”)

means if it is true it has to do the same steps which is under Main logic så i do not know how to do that…
can someone help please

it workes like this… the solution is right but i want to combine last 2 if statements…

@ppr @Palaniyappan @Keerthivas @Yurii_Horobets kindly help

Maybe you should try

row(“CodeDescription”).ToString.Contains(“Start Vacation”) And dtExcelSheetData.Rows(intRowCounter)(“ID-number”).ToString.Equals(dtExcelSheetData.Rows(intRowCounter+1)(“ID-number”).ToString)

it gives error because row(“CodeDescription”) does not belong to table… and that what i want to make that when this is not avaiable it should continue

CodeDescription seems to be a column. How it may not belong to a table?
Nevertheless, you may surround that if with try-catch

because some excel file have not that column… let say I have 7 excel file and 5 have same column and 2 file have some ekstra columns… and when i have those 2 files data then i need to check the specifik column and take in concidration to find the right “specifik” data to register to system.

thet way i need this otherwise my code is working perfect… just because of this when i have that specifik file i need one ekstra step to check but the rest code og activities i do is same… on both senario.

can some one help