Copy data to another file

I want to check sheet exist

  • if have sheet1 and sheet2 copy column A-C
    merge 2 sheet to 1 datatable and sort column Planned End (ascending) —> append data to file summary sheet Summary1.

  • if have sheet1 only copy column A-C ------> append data to file summary sheet Summary1.
  • if have sheet2 only copy column A-C ------> append data to file summary sheet Summary1.
  • if don’t have sheet1 or sheet2 -----> end

Please guide me for solve it.

File as attached.

Summary.xlsx (9.5 KB)
input (1).xlsx (11.7 KB)

Expect output = file summary sheet Expect_output

Pease guide me for solve it.
Thsnk you.

Can guide me for solve it.

Thank you.

HI,

How about the following sample?

Sample
Sample20240319-2 (2).zip (19.5 KB)

Regards,

1 Like

@Yoichi I want copy data from column A-C only.
and write range workbook I want tot write in append row ( can’t fix A3)

image

Please guide me about it.

Thank you

HI,

Can you try the following?

image

dtResult.DefaultView.ToTable(False,{"Status","Owner","Planned End"}).AsEnumerable.OrderBy(Function(r) CDate(r("Planned End"))).CopyToDataTable

Sample20240319-2 (3).zip (19.6 KB)

Regards,

1 Like

@Yoichi I have a question in append range.
If I don’t use column name because real data have 20 column.

Do you have idea for use column A-T don’t use column name?

Give it a try the following expression. This filters the first 20 columns.

dtResult.DefaultView.ToTable(False,dtResult.Columns.Cast(Of DataColumn).Take(20).Select(Function(dc) dc.ColumnName).ToArray()).AsEnumerable.OrderBy(Function(r) CDate(r("Planned End"))).CopyToDataTable

Regards,

1 Like

@Yoichi now use if​ inside if.
It​ can​ modify to​ use switch​ case​ or not.

Please guide me for​ solve it.
Thank​ you.

In this case, we can write multiple IF activities flatly as the following. How about this?

Sample
Sample20240319-2 (5).zip (19.6 KB)

Regards,

1 Like

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