VBC code to copy and paste data from one sheet to another

vnoreau

New Member
Joined
Jun 4, 2013
Messages
17
Office Version
  1. 365
Platform
  1. Windows
Hello, I am not sure if I will explain this well but let's try. What I need is a vba code to copy and paste data from one sheet to another. Each time the macro would be run, the amount of data would change. (Meaning the amount of rows will vary each time). The data would be contained between columns A and M on sheet named DATA, and the total rows vary. I need it pasted into sheet named Template in rows C to N, starting at row 7.Thank you for your help.
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
hi vnoreau
try the following ( not the best bit of code you will see but it works

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
x = Range("a" & Rows.Count).End(xlUp).Row
y = 1
Range("a" & y & ":m" & x).Copy
y = 7: x = x + 7
Sheets("template").Range("a" & y & ":m" & x).PasteSpecial xlPasteValues
Application.CutCopyMode = False
End Sub

cheers

kevin
 
Upvote 0

Forum statistics

Threads
1,216,071
Messages
6,128,628
Members
449,460
Latest member
jgharbawi

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