How to copy and paste the value from pivot to another sheet

Hi All,

I am facing challenge in pasting the data copied from pivot. I want to make it dynamic for all years data month wise. I need to copy each year data for all 12 rows(row here is month).

The same data is to be pasted in another sheet as shown below:
the data should be same as year and month wise as mentioned in pivot.

How can I achieve this? Please help me out.

Hi @Asfaque

Follow the steps

  1. Read all the data in to datatablr(dt) with add headers checked starting from cell A2
  2. Build a datatble with 3 columns as required(newdt)
  3. Use fore each loop with Enumerable.Range(0,dt.Columns.count).ToArray() this will loop through all columns(make sure to change the type argument to int32
  4. Inside that use for each row in datatable dt
  5. Inside the second loop use add datatrow on newdt with row array as {dt.Columns(currentitem).columnname,currentrow(0).Tostring,currentrow(dt.Columns(currentitem).columnname).tostring}

Hope this helps


Thanks @Anil_G. It worked

1 Like

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