0

This seems like a very simple problem. The following macro fails on the line: Set RngS = wsS.Range(Cells(8, 1), Cells(21, 13)) Error 1004: "Method 'range of object'_Worksheet failed."

Thoughts? Thank you.

Sub CreateSummaryNew()
Dim Pn, As Integer
Dim RngP, RngS As Range
Dim wsP, wsS As Worksheet

Pn = ActiveSheet.Range("G3")
Set wsP = ActiveWorkbook.Sheets(Pn)
Set wsS = ActiveWorkbook.Sheets(Pn + 30)

Set RngP = wsP.Range(Cells(8, 31), Cells(21, 43))
Set RngS = wsS.Range(Cells(8, 1), Cells(21, 13))
RngP.Copy (RngS.PasteSpecial(Paste:=xlPasteValues))

End Sub
Kerry
  • 1
  • 1
    qualify `cells` with a worksheet – Warcupine May 09 '22 at 19:36
  • 1
    Also, in this line `Dim RngP, RngS As Range` only `RngS` is a Range, `RngP` is of type Variant – Spectral Instance May 09 '22 at 19:39
  • Is the code located In the same workbook containing the worksheets `Worksheets(Pn)` and `Worksheets(Pn+30)` and what are their names? Is `ActiveSheet` in the same workbook? What is the tab name or the index of `Activesheet`? – VBasic2008 May 09 '22 at 19:48

0 Answers0