Copy Paste Multiple Columns To Another Sheet

unknownymous

Board Regular
Joined
Sep 19, 2017
Messages
249
Office Version
  1. 2016
Platform
  1. Windows
Hi Guys,

Need some help here. So I have a workbook with filename "Master Data" with tab sheets namely "Main File" and "Final".

Main File Data look like this"

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Name[/TD]
[TD]Stat 1[/TD]
[TD]Stat 2[/TD]
[TD] PrevStat[/TD]
[TD]Subject1[/TD]
[TD]Subject2 [/TD]
[TD]Subject 3[/TD]
[/TR]
[TR]
[TD]Eve[/TD]
[TD]9[/TD]
[TD]6[/TD]
[TD]10[/TD]
[TD]Math[/TD]
[TD]Science[/TD]
[TD]PE[/TD]
[/TR]
[TR]
[TD]Mon[/TD]
[TD]7[/TD]
[TD]5[/TD]
[TD]15[/TD]
[TD]History[/TD]
[TD]PE[/TD]
[TD]Geo[/TD]
[/TR]
[TR]
[TD]Sam[/TD]
[TD]4[/TD]
[TD]7[/TD]
[TD]8[/TD]
[TD]PE[/TD]
[TD]Math[/TD]
[TD]PolSci[/TD]
[/TR]
[TR]
[TD]Belle[/TD]
[TD]4[/TD]
[TD]2[/TD]
[TD]6[/TD]
[TD]Math[/TD]
[TD]Sciene[/TD]
[TD]History[/TD]
[/TR]
</tbody>[/TABLE]


I'm looking for the codes where the macro will copy the data from the "Master Data" to "Final" tab and the result will look like below.
By the way, the "Current Stat" is the result of summing up "Stat1" and "Stat 2"

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Name[/TD]
[TD]Subject1[/TD]
[TD]Subject2[/TD]
[TD]Subject3[/TD]
[TD]Current Stat[/TD]
[TD]PrevStat[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Even[/TD]
[TD]Math [/TD]
[TD]Science[/TD]
[TD]PE[/TD]
[TD]15[/TD]
[TD]10[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Mon[/TD]
[TD]History[/TD]
[TD]PE[/TD]
[TD]Geo[/TD]
[TD]12[/TD]
[TD]15[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Sam[/TD]
[TD]PE[/TD]
[TD]Math[/TD]
[TD]PolSci[/TD]
[TD]11[/TD]
[TD]8[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]Belle[/TD]
[TD]Math[/TD]
[TD]Science[/TD]
[TD]History[/TD]
[TD]6[/TD]
[TD]6[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]


Any help will be much appreciated.
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
Try this:
Code:
Sub Test()
'Modified 6/29/2018 5:12 AM  EDT
Application.ScreenUpdating = False
Dim i As Long
Sheets("Main File").Activate
Dim Lastrow As Long
Lastrow = Sheets("Final").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("Final").Cells(1, 1).Resize(Lastrow, 6).ClearContents
Lastrow = Sheets("Main File").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("Main File").Cells(1, "A").Resize(Lastrow).Copy Sheets("Final").Cells(1, 1)
Lastrow = Sheets("Main File").Cells(Rows.Count, "E").End(xlUp).Row
Sheets("Main File").Cells(1, "E").Resize(Lastrow, 3).Copy Sheets("Final").Cells(1, 2)
Lastrow = Sheets("Main File").Cells(Rows.Count, "D").End(xlUp).Row
Sheets("Main File").Cells(1, "D").Resize(Lastrow).Copy Sheets("Final").Cells(1, "F")
Sheets("Final").Cells(1, "E").Value = "Current Stat"
Lastrow = Sheets("Main File").Cells(Rows.Count, "B").End(xlUp).Row
For i = 2 To Lastrow
Sheets("Final").Cells(i, "E").Value = Cells(i, "b").Value + Cells(i, "C").Value
Next
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,310
Members
452,634
Latest member
cpostell

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