Attach to the cell above if there is a blank space help

Hello!
I’m working on a development where, if cell E is empty, the value in cell F above should be appended to the text in the upper F cell.
I tried using a code like “=IF(E3=”“, F2, F2 & E3)”, but it didn’t work.
I’ve been struggling to find another solution, but I can’t seem to achieve the desired condition. Could you please provide guidance on how to meet this condition?
Thank you in advance for your response!

@22222222asas

  1. Read Excel Data:

    • Excel Application Scope: Provide the Excel file path.
    • Read Range: Read the data into a DataTable. Let’s say the DataTable is named dt.
  2. Process Data:

    • For Each Row: Iterate through each row in the DataTable (dt).
      • Assign activity: Check if cell E is empty.
        • Condition: String.IsNullOrEmpty(row("E").ToString)
        • If true, update the value in cell F based on the condition.
          • Assign activity: row("F") = row("F").ToString & row("E").ToString
  3. Write Updated Data:

    • Write Range: Write the updated DataTable (dt) back to the Excel file.
1 Like

@Krishna_Raj
Thank you for your response!
I’m sorry, but I’m having a bit of trouble understanding, so could you please explain the code with a screenshot?
I really appreciate it!"

Hi,

How about the following sample?

Sample
Sample20240125-5.zip (8.4 KB)

Regards,

1 Like

Hi @22222222asas ,

You just need a bit of an updation in your formula i.e. “=IF(E3=‘’”,F2, F2&F3)"

1 Like

@Yoichi
Thank you for your response!
It works well, but I encounter an error when there are multiple items.
Is there a solution for this? Using “Foreach ROW IN DT” causes an error.
I have attached a screenshot for your reference. Thanks in advance for your assistance!


@AMAN_GUPTA
Thank you for your response!
I’m sorry, but I’m having a bit of trouble understanding, so could you please explain the code with a screenshot?
I really appreciate it!"

HI,

How about the following?

Sample
Sample20240125-5 (2).zip (14.8 KB)

Regards,

1 Like

@Yoichi
Thank you for your response!
When I ran the code you suggested, the robot terminates before reaching “ForEach row in dt.” Could you please provide insights into the reason for this?

Hi,

To isolate cause, can you try to turn on LogActivites button on ribbon then debug run?
And also can you check if dt has datarow or not using BrreakPoint etc?

Regards,

1 Like

@Yoichi
Thank you for your response!

Hi,

The log shows datatable is empty.
Can you share reason you use GenerateDataTable activity? How about using ReadRange like my sample?

Regards,

1 Like

@Yoichi
Thank you for your response!
I ran the code you suggested, but it seems I confused it with the code I wrote.
I apologize for the confusion, and I really appreciate your guidance!
Your advice was exactly what I was looking for.
Thanks again for your response!

1 Like

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