VBA

xxsalahxx

Active Member
Joined
Jun 25, 2011
Messages
259
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

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

mrshl9898

Well-known Member
Joined
Feb 6, 2012
Messages
1,791
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
 
Solution

Watch MrExcel Video

Forum statistics

Threads
1,130,060
Messages
5,639,828
Members
417,117
Latest member
Ravi Pandey

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
Top