Help in copying the data to the specified sheet with calculating the sum of the columns

sofas

Active Member
Joined
Sep 11, 2022
Messages
468
Office Version
  1. 2019
Platform
  1. Windows
Welcome . Please help in creating a code that enables me to copy and sort the data so that the values are copied into an excel sheet whose name is in column A

I have a file of 10 excel sheets
I want to copy each row in its excel sheet with addition in the last row of plurals for columns automatically and when copying again the sum is updated
1.PNG

Example

3.PNG

I created this code, but I can't get the sum of the columns


VBA Code:
Sub copy()
ActiveSheet.unprotect
Set ws = ActiveWorkbook.Sheets("data")
Dim cl As Range, i As Integer
For i = 1 To Sheets.Count
For Each cl In ws.Range("a13:a" & ws.[a10000].End(xlUp).Row)
If cl.Value = Sheets(i).Name Then

Sheets(i).Range("a" & Sheets(i).[a10000].End(xlUp).Row + 1).EntireRow.Insert

Sheets("data").Select
cl.Offset(0, 2).Resize(1, 5).copy
Sheets(i).Range("a" & Sheets(i).[a10000].End(xlUp).Row + 1).PasteSpecial xlPasteValues
End If
Next
Next
End Sub
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.

Forum statistics

Threads
1,214,936
Messages
6,122,340
Members
449,079
Latest member
rocketslinger

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top