VBA

xxsalahxx

Active Member
Joined
Jun 25, 2011
Messages
316
Office Version
  1. 2007
Hello I am using a vba to copy data from Sheet1 onto another tab Sheet2 however if I would like this data to also copy into Sheet3 and Sheet4 how would i adjust this vba to accomodate this? Im a novice at macros so im just learning and this is puzzling me.
Thank you in advance for any help

Sub Copy_Data()
'
'
Dim Sht1 As Worksheet
Dim Sht2 As Worksheet
Dim CpyRng As Range
Dim L As Long
'
Set Sht1 = ActiveWorkbook.Sheets("Sheet1")
Set Sht2 = ActiveWorkbook.Sheets("Sheet2")
L = Sht1.Cells(Rows.Count, 1).End(xlUp).Row
Set CpyRng = Sht1.Range("A2:Z" & L)
'
CpyRng.Copy
Sht2.Range("A1").PasteSpecial
Application.CutCopyMode = False
'
'
End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
try:

Power Query:
Sub Copy_Data()
'
'
Dim Sht1 As Worksheet
Dim Sht2 As Worksheet
Dim Sht3 As Worksheet
Dim Sht4 As Worksheet
Dim CpyRng As Range
Dim L As Long
'
Set Sht1 = ActiveWorkbook.Sheets("Sheet1")
Set Sht2 = ActiveWorkbook.Sheets("Sheet2")
Set Sht3 = ActiveWorkbook.Sheets("Sheet3")
Set Sht4 = ActiveWorkbook.Sheets("Sheet4")
L = Sht1.Cells(Rows.Count, 1).End(xlUp).Row
Set CpyRng = Sht1.Range("A2:Z" & L)
'
CpyRng.Copy
Sht2.Range("A1").PasteSpecial
Sht3.Range("A1").PasteSpecial
Sht4.Range("A1").PasteSpecial
Application.CutCopyMode = False
'
'
End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,214,833
Messages
6,121,867
Members
449,053
Latest member
Mesh

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