Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Macro correction

Hi,
I've got the following code to copy every 3rd cell in col C starting from
the last row -1 and paste into next blank row +1 of col A in different
workbook. This works great.
Then I tried to alter it to do a similar action...
Copy every 3rd cell in col C starting from the last row and paste into next
blank row +1 of col H in other workbook.

At the moment the second part of the code copies the same values as the
first part, what do I change to copy the last cell in col C not the one
above?? I've fiddled with the End(xlUp) part but then get errors.

Any help greatly appreciated, thanks...

'Copy every 3rd cell in column C starting one row before the last row, and
paste into next blank row +1 in LFmacro worksheet col A
For i = 1 To Cells(Rows.Count, "c").End(xlUp).Row Step 3
With Workbooks("LFmacro.xls").Sheets("Report")
Lr = .Cells(Rows.Count, "A").End(xlUp).Row + 1
Cells(i, "c").Copy .Cells(Lr, "A")
End With
Next i

'Copy every 3rd cell in column C starting at the last row, and paste into
next blank row +1 in LFmacro worksheet col H
Windows("Discreps.xls").Activate
For i = 1 To Cells(Rows.Count, "c").End(xlUp).Row Step 3
With Workbooks("LFmacro.xls").Sheets("Report")
Lr = .Cells(Rows.Count, "H").End(xlUp).Row + 1
Cells(i, "c").Copy .Cells(Lr, "H")
End With
Next i

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Macro correction

Windows("Discreps.xls").Activate
For i = 1 To Cells(Rows.Count, "c").End(xlUp).Row Step 3
With Workbooks("LFmacro.xls").Sheets("Report")
Lr = .Cells(Rows.Count, "H").End(xlUp).Row + 1
Cells(i + 1, "c").Copy .Cells(Lr, "H")
End With
Next i

--
Regards,
Tom Ogilvy



"Meltad" wrote:

Hi,
I've got the following code to copy every 3rd cell in col C starting from
the last row -1 and paste into next blank row +1 of col A in different
workbook. This works great.
Then I tried to alter it to do a similar action...
Copy every 3rd cell in col C starting from the last row and paste into next
blank row +1 of col H in other workbook.

At the moment the second part of the code copies the same values as the
first part, what do I change to copy the last cell in col C not the one
above?? I've fiddled with the End(xlUp) part but then get errors.

Any help greatly appreciated, thanks...

'Copy every 3rd cell in column C starting one row before the last row, and
paste into next blank row +1 in LFmacro worksheet col A
For i = 1 To Cells(Rows.Count, "c").End(xlUp).Row Step 3
With Workbooks("LFmacro.xls").Sheets("Report")
Lr = .Cells(Rows.Count, "A").End(xlUp).Row + 1
Cells(i, "c").Copy .Cells(Lr, "A")
End With
Next i

'Copy every 3rd cell in column C starting at the last row, and paste into
next blank row +1 in LFmacro worksheet col H
Windows("Discreps.xls").Activate
For i = 1 To Cells(Rows.Count, "c").End(xlUp).Row Step 3
With Workbooks("LFmacro.xls").Sheets("Report")
Lr = .Cells(Rows.Count, "H").End(xlUp).Row + 1
Cells(i, "c").Copy .Cells(Lr, "H")
End With
Next i

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 98
Default Macro correction

Thanks Tom,
i +1!!!

"Tom Ogilvy" wrote:

Windows("Discreps.xls").Activate
For i = 1 To Cells(Rows.Count, "c").End(xlUp).Row Step 3
With Workbooks("LFmacro.xls").Sheets("Report")
Lr = .Cells(Rows.Count, "H").End(xlUp).Row + 1
Cells(i + 1, "c").Copy .Cells(Lr, "H")
End With
Next i

--
Regards,
Tom Ogilvy



"Meltad" wrote:

Hi,
I've got the following code to copy every 3rd cell in col C starting from
the last row -1 and paste into next blank row +1 of col A in different
workbook. This works great.
Then I tried to alter it to do a similar action...
Copy every 3rd cell in col C starting from the last row and paste into next
blank row +1 of col H in other workbook.

At the moment the second part of the code copies the same values as the
first part, what do I change to copy the last cell in col C not the one
above?? I've fiddled with the End(xlUp) part but then get errors.

Any help greatly appreciated, thanks...

'Copy every 3rd cell in column C starting one row before the last row, and
paste into next blank row +1 in LFmacro worksheet col A
For i = 1 To Cells(Rows.Count, "c").End(xlUp).Row Step 3
With Workbooks("LFmacro.xls").Sheets("Report")
Lr = .Cells(Rows.Count, "A").End(xlUp).Row + 1
Cells(i, "c").Copy .Cells(Lr, "A")
End With
Next i

'Copy every 3rd cell in column C starting at the last row, and paste into
next blank row +1 in LFmacro worksheet col H
Windows("Discreps.xls").Activate
For i = 1 To Cells(Rows.Count, "c").End(xlUp).Row Step 3
With Workbooks("LFmacro.xls").Sheets("Report")
Lr = .Cells(Rows.Count, "H").End(xlUp).Row + 1
Cells(i, "c").Copy .Cells(Lr, "H")
End With
Next i

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Value correction P. Zicari Excel Discussion (Misc queries) 2 April 15th 08 07:28 PM
advanced "Replace" macro = correction markx Excel Programming 4 July 27th 06 05:42 PM
advanced "Replace" macro = correction Jim May Excel Programming 1 July 27th 06 02:38 PM
correction nowfal Excel Discussion (Misc queries) 4 March 24th 06 06:40 PM
Excel Autofilling to 65543-need macro correction Frantic Excel-er Excel Discussion (Misc queries) 2 June 23rd 05 06:48 PM


All times are GMT +1. The time now is 02:10 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"