I have an Excel file with bulk data. For example, check if cell I3 contains the value "CHECK". If yes, then verify whether L4 is null or empty. If that condition is also met, check if L5 is greater than 0. If all conditions are satisfied, extract the data

Hi Team,

I have an Excel file with bulk data. For example, check if cell I3 contains the value “CHECK”. If yes, then verify whether L4 is null or empty. If that condition is also met, check if L5 is greater than 0. If all conditions are satisfied, extract the data (e.g., AB031) from I5 and update I3 by incrementing the number (e.g., AB032) using Workbook activities in Excel with UiPath.

This is just an example. I need to apply the same logic across the entire Excel sheet. For each iteration, check the value in column L (Double type). If the value is null or empty, continue to the next row until a value greater than 0 is found. Then extract the corresponding data from column I and update the current cell by incrementing the number accordingly.

Hi @Hansi,

Read Excel → DataTable
Use Read Range (Workbook) → output: dtData

Loop through rows
Use For Each Row in DataTable

Apply condition (LINQ / If inside loop)

If row("I").ToString.Trim.Equals("CHECK") Then
    
    'Check next row (L is empty)
    If String.IsNullOrWhiteSpace(dtData.Rows(rowIndex + 1)("L").ToString) Then
        
        'Check next to next row (L > 0)
        If CDbl(dtData.Rows(rowIndex + 2)("L").ToString) > 0 Then
            
            'Extract value from I column
            extractedValue = dtData.Rows(rowIndex + 2)("I").ToString
            
            'Increment value (example AB031 → AB032)
            prefix = System.Text.RegularExpressions.Regex.Match(extractedValue, "[A-Za-z]+").Value
            number = CInt(System.Text.RegularExpressions.Regex.Match(extractedValue, "\d+").Value)
            newValue = prefix + (number + 1).ToString("D3")
            
            'Update current row
            row("I") = newValue
            
        End If
    End If
End If

Instead of hardcoding +1, +2:
Use a While loop to keep moving until L > 0 is found
Makes it scalable for real bulk data

Hi @Hansi

This linq should be of help to you.
(From row In DT.AsEnumerable
Where row(“I3”).ToString.Contains(“yourValue”) AndAlso
String.IsNullOrEmpty(row(“L4”).ToString) AndAlso
Not String.IsNullOrEmpty(row(“L5”).ToString) AndAlso
CInt(row(“L5”)) > 0
Select row).CopyToDataTable