simple copy paste multiple range macro ARGUMENT ERROR

B

Bruno

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
 
T

TomPl

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top