Merge cells in datatable

Hello everyone, I have a small technical question.
I have an Excel file that I read in data table :

In yellow: “HERE” is empty
When my C value is empty, I would like the line who is ORANGE
Go up and take the place of the BLUE

Here is my expected result :

Do you know how I can do this? THANKS

Hi @DimitriLYR ,

Thanks for reaching out to Community.

Firstly check if the value of column C is empty for the current row. You can use an If activity - String.IsNullOrEmpty(row(“C”).ToString)
Then use assig acivity ,
If activity with the condition String.IsNullOrEmpty(row(“C”).ToString).
Assign activity to set the background color of the next row to orange.
Assign activity to set the background color of the current row to blue.

Happy Automation :grinning:
Please mark this as a solution if it helps you. :writing_hand:

Regards,
@pratik.maskar

Sorry, I expressed myself badly. I would like the orange data to go back to the top row

Hi @DimitriLYR ,

I believe the example data provided by you is still not maybe representing the original data, as there are still questions that can be raised on the data.

You did mention that HERE is empty, but the line next to it is also having empty string, So what is the Difference between HERE being empty and the empty String below it ?

Are we supposed to Check for HERE or empty string. This is asked now so that it might not effect in later code developments.

Also, If you could provide the Data in the form of Excel sheet, it would helpful to investigate faster.

@DimitriLYR

If I understand correctly…whenever you see an empty cell in C column then you want the data from next row to be populated to the current row

You can read the data into datatable…

Then use for each row in datatble and inside that use write cell activity if if condition

  1. For each row in datatable…and in properties of for loop assign the index to a variable index
  2. Use a if condition to check for empty IsNothing(currentorw("ColC")) OrElse String.IsNullOrEmpty(currentrow("ColC").ToString.Trim)
  3. On the then side use write cell activity will value as dt.Rows(index+1)(“Requiredcolumnname”).ToString and cell value as "D" + (index+2).ToString …change D to any column you want to write into

Cheers

1 Like

That’s exactly it, I got lost in my explanations, please excuse me

1 Like

Hi @DimitriLYR ,
No problem ,
Then in this case do this( go step by step).
For Each Row activity to loop through the DataTable.
If activity with the condition String.IsNullOrEmpty(row(“C”).ToString).
assign activity to store the values of the current row in a DataRow variable.
If activity with the condition previousRowOrange AndAlso Not IsNothing(orangeRow).
assign activity to replace the current row with the orange row.
assign activity to set the background color of the current row to blue.
assign activity to set the Boolean variable previousRowOrange to the result of the previous If activity.
End the For Each.

Regards,
@pratik.maskar :grinning:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.