Consulting

Results 1 to 15 of 15

Thread: Subscript out of range problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Apr 2019
    Location
    London
    Posts
    25
    Location

    Subscript out of range problem

    Can you see why the following code generates a "subscript out of range" error at the last line?
    The Sheets(Sh) convention works elsewhere. The Rng1A.copy seems to have taken place ok.


    Dim Rng1A, Rng2A, Rng1I, Rng2I As Range   'range blocks to copy
    Dim N as Long, D As Date, Sh As String
    N = ActiveWorkbook.Sheets("NAVIGATION").Range("G12")   ' value is correct
            D = ActiveWorkbook.Sheets("NAVIGATION").Range("H13")    ' value is correct
            Sh = "Sheet" & N                                                                ' value is correct
    With ActiveWorkbook.Sheets("INV ACC")
                Set Rng1A = Range("D15:I214") 
                Set Rng2A = Range("M15:W214") 
            End With
    With ActiveWorkbook.Sheets("INV INPUT")
                Set Rng1I = Range("H15:L214")  
                Set Rng2I = Range("S15:Y214")  
            End With
    Rng1A.Copy
                Workbooks("Centris Periods.xlsm").Sheets(Sh).Range("D15:I214").PasteSpecial xlPasteValuesAndNumberFormats
    Thank very much.
    Last edited by Aussiebear; 04-18-2019 at 12:16 AM. Reason: wrapped submitted code in tags

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •