Copy the format of first row to succeeding rows

Hi!

I need help with my project.

Using this image as reference:

I need to format the row 4 onwards with the same format that I have in row 1. Is there any way I can do this without reading the whole excel file?

I’m using the Use Excel File activity.

Thank you so much!

Hi @_pjflo

You should use the “Copy/Paste Range” Activity within your “Use Excel File” Scope that you mentioned. This allows you to copy the format of cells and ranges.

You’d have to provide three parameters:

  • Source: Excel.Sheet(“SheetName”).Range(“A2:G2”)
  • Destination: Excel.Sheet(“SheetName”).Range(“A4:G6”)
  • What to copy: Formats

(ignore “Exclude source headers” and “Transpose” - keep the boxes unchecked)

Note that you could provide dynamic Range parameters such as:
Excel.Sheet(“SheetName”).Range(“A” + int_StartRow.ToString + “:G” + int_EndRow.ToString) if you find the LastRow of your Excel Table (and this needs to be dynamic).

Hope this helps!

Best regards
Roman

@_pjflo

Is the format always same? Or will it change?

If its same…and if you can use a template excel then you can format the excel before hand using conditional formatting and have it…so once value is filled it will get auto formatted

If template is not possible but the format is same…then you can go with format cell activity and set the format and change range values where you want to apply

If format also changes then you need to go with a vba …which copies the format from about to bottom

Hope this helps

Cheers

Your solution works! Thanks a lot!

Hi, thank you for your help! I will definitely consider your advice.

1 Like

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