hi my friends.
I’ve been having problems with a loop for a long time. Can someone kindly solve my problem? I’ve asked a few times but can’t find a solution myself. I have two codes as string variables and I want to search in Excel and if both codes are found in a column then write risk to the end of the column. but it has to find both in the same column. that is, the two must not be in the same column. I will be very grateful if someone develops this loop for me and sends it here. Thank you
Hello @a.hezardastan, try this out:
Excel Application Scope (Open Excel File)
Read Range (Read Excel Data into dtExcel)
For Each Row (Loop through dtExcel)
If (row(“ColumnName”).ToString.Contains(code1) AndAlso row(“ColumnName”).ToString.Contains(code2))
Assign (row(“ColumnName”) = row(“ColumnName”).ToString & " risk")
End If
End For Each
Write Range (Write dtExcel back to Excel)
Close Workbook (Close Excel File)
Cheers!
thanks but that doesn’t work. there are a few errors. please try it yourself
For each excel row:
if currentrow(“column”).tostring.equals(code1)
assign flag1=true
if currentrow(“column”).tostring.equals(code2)
assign flag2=true
Outside for each:
if flag1=true and flag2=true
write risk
thanks but that doesn’t work
Whats not working, please share screenshot