Pasting a set of rows under existing set of rows


Here is my input (read range):

Now I want an output in a new sheet like this:


Basically in need all the names in one row and all the roll Numbers in another row

Number of rows and columns (in Input sheet) are dynamic and not fixed.

Thanks a lot

Hi @Bhanu_Rathore
Use read range and store the excel in dt1

now use two assign activity

dt2 = dt1.DefaultView.ToTable(False,{“Name_Class1”,“Roll. No_1”})

dt3= dt1.DefaultView.ToTable(False,{“Name_Class2”,“Roll. No_2”})

Now use merge datatable to merge the dt2, dt3 to a datatable , let’s say dt4

Now write the dt4 in excel sheet

Nived N
Happy Automation

Just to highlight if the column names are different it won’t get merged

And more over we are using assign here but it’s stated that the number of column are dynamic

I m also trying to find a way for this
Will get back to you

Did u mean whether the columns name are like Name_Class3 like that…?

Hi @Bhanu_Rathore

With what @NIVED_NAMBIAR and @Palaniyappan if merge datatable can’t be used if column names are different try these steps,

  1. Read the excel data in the datatable.dt variable name

  2. Use write range and give range as “A1” and check add headers property, give datatable as dt.DefaultView.ToTable(False,{“Name_Class1”,“Roll. No_1”}) and give the sheet name.

  3. Again use read range and read the newly created sheet and store in a datatable dt2 variable name.

  4. Now use write range and give range as “A” + dt2.rows.count.tostring, uncheck add headers property,give datatable as dt.DefaultView.ToTable(False,{“Name_Class2”,“Roll. No_2”}) and give the sheet name.

For this method though ,Column and row count can be dynamic but the column names have to be static.


1 Like

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