Copy Columns from one sheet to another using macro/formula

jarrodexcel

New Member
Joined
Dec 14, 2022
Messages
23
Office Version
  1. 365
Platform
  1. Windows
Hey guys,

As the title says, i have two sheets named A and B. I import excel data from a report into sheet A with columns going from a - z, what i am trying to do is set up a formula or macro on sheet B that will automatically fill data from specific columns in sheet A to sheet B. IE Sheet A columns a,c,d,f,t,s,z will automatically fill over into sheet B.

Any help would be massively appreciated ! thank you

Jarrod
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Try something like this:

VBA Code:
Sub Replicate()
Dim lastrow As Long
lastrow = Sheets("A").Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row

Sheets("A").Range("A1:A" & lastrow).Copy Sheets("B").Range("A1")
Sheets("A").Range("C1:C" & lastrow).Copy Sheets("B").Range("C1")
Sheets("A").Range("D1:D" & lastrow).Copy Sheets("B").Range("D1")
Sheets("A").Range("F1:F" & lastrow).Copy Sheets("B").Range("F1")
Sheets("A").Range("T1:T" & lastrow).Copy Sheets("B").Range("T1")
Sheets("A").Range("S1:S" & lastrow).Copy Sheets("B").Range("S1")
Sheets("A").Range("Z1:Z" & lastrow).Copy Sheets("B").Range("Z1")

End Sub
 
Upvote 0
Try something like this:

VBA Code:
Sub Replicate()
Dim lastrow As Long
lastrow = Sheets("A").Cells.Find("*", searchorder:=xlByRows, searchdirection:=xlPrevious).Row

Sheets("A").Range("A1:A" & lastrow).Copy Sheets("B").Range("A1")
Sheets("A").Range("C1:C" & lastrow).Copy Sheets("B").Range("C1")
Sheets("A").Range("D1:D" & lastrow).Copy Sheets("B").Range("D1")
Sheets("A").Range("F1:F" & lastrow).Copy Sheets("B").Range("F1")
Sheets("A").Range("T1:T" & lastrow).Copy Sheets("B").Range("T1")
Sheets("A").Range("S1:S" & lastrow).Copy Sheets("B").Range("S1")
Sheets("A").Range("Z1:Z" & lastrow).Copy Sheets("B").Range("Z1")

End Sub
Perfect! worked an absolute treat ! thank you
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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