• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Copy And Paste

Manuel998

Member
Hi

need a macro to copy and paste the colums each week(please not this is only a snap of the data I have a lot of these hence the need for a macro)

I would Greatly appreciate your help on this (spreadsheet attached).

Thanks
Manuel

PS i have also listed my ask in the spreadsheet.
 

Attachments

  • OPG.xlsx
    9.5 KB · Views: 9
Code:
Option Explicit

Sub Manuel()
    Dim lr As Long
    lr = Range("H" & Rows.Count).End(xlUp).Row
    Dim rng As Range
    Set rng = Range("D2:H" & lr)
    rng.Copy
    Range("C2").PasteSpecial xlPasteValues
End Sub
 
Hi Alan,

thanks for this any ideas how i could replicate your code for this worksheet?

Thanks
 

Attachments

  • OPG 2.xlsx
    94.6 KB · Views: 3
Give this a try:

Code:
Option Explicit
   
Sub Manuel()
    Application.ScreenUpdating = False
    Dim lr As Long, i As Long
    lr = Range("C" & Rows.Count).End(xlUp).Row
    For i = 2 To lr - 5
    Dim rng As Range, rng2 As Range
    Set rng = Range("D" & i & ":H" & i + 4)
    Set rng2 = Range("M" & i & ":Q" & i + 4)
    rng.Copy
    Range("C" & i).PasteSpecial xlPasteValues
    rng2.Copy
    Range("L" & i).PasteSpecial xlPasteValues
    i = i + 7
    Next i
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    MsgBox "complete"
End Sub
 
Hi Alan,

I gave the above a try however the only issue is that some of the cells dont get updated (i have attache d these on the spreadsheet marked in red). I would greatly appreciate if you could help me out on this.

Thanks
 

Attachments

  • OPG 2.xlsm
    98.2 KB · Views: 4
I have tried to adjust the columns and rows but not entirely sure why its not picking the middle section of the data in the spreadsheet. I would really appreciate your help on this.

Thanks
 
I found an error in my code. Try this and advise if you still are having issues.

Code:
Sub Manuel()
    Application.ScreenUpdating = False
    Dim lr As Long, i As Long
    lr = Range("C" & Rows.Count).End(xlUp).Row
    For i = 2 To lr - 5
    Dim rng As Range, rng2 As Range
    Set rng = Range("D" & i & ":H" & i + 4)
    Set rng2 = Range("M" & i & ":Q" & i + 4)
    rng.Copy
    Range("C" & i).PasteSpecial xlPasteValues
    rng2.Copy
    Range("L" & i).PasteSpecial xlPasteValues
    i = i + 6
    Next i
    Application.CutCopyMode = False
    Application.ScreenUpdating = True
    MsgBox "complete"
End Sub
 
Back
Top