Macro to copy dta from Col c to D

howard

Well-known Member
Joined
Jun 26, 2006
Messages
6,563
Office Version
  1. 2021
Platform
  1. Windows
I have written code to copy data from Col C to D on all sheets except the first sheet and the last two sheets.

However, when running the macro , no data is being copied from Col C to D

It would be appreciated if someone can correct my macro

Code:
 Sub Copy_data()
Application.DisplayAlerts = False

Dim i As Long
For i = 2 To Worksheets.Count - 2

LR = Cells(Rows.Count, 1).End(xlUp).Row
Range("C1:C" & LR).Copy Destination:=Range("D1")
Application.CutCopyMode = False
Next
End Sub
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Howard, try the code below...

Rich (BB code):
Sub Copy_data()
Application.DisplayAlerts = False

Dim i As Long, LR As Long
For i = 2 To Worksheets.Count - 2

LR = Worksheets(i).Cells(Rows.Count, 1).End(xlUp).Row
Worksheets(i).Range("C1:C" & LR).Copy Destination:=Worksheets(i).Range("D1")

Next
End Sub
 
Upvote 0
Hi Mark

Thanks for the help, code works perfectly

Regards

Howard
 
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

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