Macro to copy dta from Col c to D

howard

Well-known Member
Joined
Jun 26, 2006
Messages
5,701
Office Version
  1. 2019
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
 

Some videos you may like

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
13,827
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile
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
 

howard

Well-known Member
Joined
Jun 26, 2006
Messages
5,701
Office Version
  1. 2019
Platform
  1. Windows
Hi Mark

Thanks for the help, code works perfectly

Regards

Howard
 

Watch MrExcel Video

Forum statistics

Threads
1,122,371
Messages
5,595,784
Members
414,020
Latest member
Meghdad

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