I need help solving an RPA, I get an excel with column A blank and I need to fill it in based on column C and D.
The condition is:
1st - When columns C and D are filled with numbers, the sequence in Column A is normal
2nd - When blocks with M in columns C and D, the sequence is repeated in Column A.
Note: When there is M in columns C and D, we must have T in one of the columns below until we find another M, or columns C and D are filled with numbers.
Dim counter As Integer = 1
Dim pause As Boolean = False
dt_result = dt.Clone()
For Each row As DataRow In dt.Rows
Dim cVal As String = row("Debit").ToString().Trim()
Dim dVal As String = row("Credit").ToString().Trim()
Dim newRow As DataRow = dt_result.NewRow()
newRow.ItemArray = CType(row.ItemArray.Clone(), Object())
If pause Then
If cVal = "T" Or dVal = "T" Then
newRow("Sequence") = counter.ToString()
Else
counter += 1
pause = False
newRow("Sequence") = counter.ToString
End If
Else
If cVal = "M" Or dVal = "M" Then
pause = True
newRow("Sequence") = counter.ToString
Else
pause = False
newRow("Sequence") = counter.ToString()
counter += 1
End If
End If
dt_result.Rows.Add(newRow)
Next
' Assign the result back to dt if needed:
dt = dt_result