![]() |
simple copy paste multiple range macro ARGUMENT ERROR
I need to copy a multiple range of cells and recalculate the values with the
new constants. I got solved the copy part with some help, but now i can't get the paste arguments right. Here's the code Sub CopyAndPasteV2() For Each sht In Sheets Select Case sht.Name Case "D": SourceRow = -1 Case "A": SourceRow = 5 Case "B": SourceRow = 6 Case Else: SourceRow = 0 End Select If SourceRow 0 Then sht.Range("a6").EntireRow.Insert Worksheets("INTRADAY").Rows(SourceRow).Copy sht.Rows(6).PasteSpecial xlValues sht.Range("C7:D7,J7:M7,P7:T7").Copy sht.Range("C6:D6,J6:M6,P6:T6").xlPasteAll End If If SourceRow = -1 Then sht.Range("a6").EntireRow.Insert End If Next sht End Sub |
simple copy paste multiple range macro ARGUMENT ERROR
This should work:
Sub CopyAndPasteV2() For Each sht In Sheets Select Case sht.Name Case "D": SourceRow = -1 Case "A": SourceRow = 5 Case "B": SourceRow = 6 Case Else: SourceRow = 0 End Select If SourceRow 0 Then sht.Range("a6").EntireRow.Insert Worksheets("INTRADAY").Rows(SourceRow).Copy sht.Rows(6).PasteSpecial xlValues sht.Range("C7:D7").Copy sht.Range("C6") sht.Range("J7:M7").Copy sht.Range("J6") sht.Range("P7:T7").Copy sht.Range("P6") End If If SourceRow = -1 Then sht.Range("a6").EntireRow.Insert End If Next sht End Sub |
simple copy paste multiple range macro ARGUMENT ERROR
WORKS LIKE A CHARM
"TomPl" wrote: This should work: Sub CopyAndPasteV2() For Each sht In Sheets Select Case sht.Name Case "D": SourceRow = -1 Case "A": SourceRow = 5 Case "B": SourceRow = 6 Case Else: SourceRow = 0 End Select If SourceRow 0 Then sht.Range("a6").EntireRow.Insert Worksheets("INTRADAY").Rows(SourceRow).Copy sht.Rows(6).PasteSpecial xlValues sht.Range("C7:D7").Copy sht.Range("C6") sht.Range("J7:M7").Copy sht.Range("J6") sht.Range("P7:T7").Copy sht.Range("P6") End If If SourceRow = -1 Then sht.Range("a6").EntireRow.Insert End If Next sht End Sub |
All times are GMT +1. The time now is 01:43 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com