Results 1 to 7 of 7

Thread: [RESOLVED] Rutime Error 1004

  1. #1

    Thread Starter
    Member
    Join Date
    May 2009
    Posts
    49

    Resolved [RESOLVED] Rutime Error 1004

    I am hung up on this Runtime error 1004. Still really new to VB

    The debuger say it fails here
    Code:
    Sheets("Matrix").Range(CompCopyRng(j), Sheets("Matrix").Range(UserformStr(i) & 65536).End(xlUp)).Copy
    Here is what I am working with.

    Code:
    Dim Filename As Variant
    Filename = MMatrixtx.Text
    Dim MMatrixws As Worksheet
    Workbooks.Open (Filename)
    Set MMatrixws = Worksheets("Matrix")
    MMatrixws.Activate
    Dim j As Integer
    Dim i As Integer
    For i = 0 To 9
       For j = 0 To 9
    
    
         Sheets("Matrix").Range(CompCopyRng(j), Sheets("Matrix").Range(UserformStr(i) & 65536).End(xlUp)).Copy
                ThisWorkbook.Sheets("SAS").Activate
                Range("P9").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
                :=False, Transpose:=False
        Next j
    Next i
    End Sub

  2. #2

    Thread Starter
    Member
    Join Date
    May 2009
    Posts
    49

    Re: Rutime Error 1004

    If i replace

    Code:
    MMatrixws.Range(CompCopyRng(j), MMatrixws.Range(UserformStr(i) & 65536).End(xlUp)).Copy
    With this it work perfect every time. This is what the above should translate too.
    Code:
    MMatrixws.Range("DO10", MMatrixws.Range("DO65536").End(xlUp)).Copy

  3. #3
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Rutime Error 1004

    try
    MMatrixws.Range(CompCopyRng(j), MMatrixws.Range(UserformStr(i) & "65536").End(xlUp)).Copy
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  4. #4

    Thread Starter
    Member
    Join Date
    May 2009
    Posts
    49

    Re: Rutime Error 1004

    Still Fails here. This is the specific section that fails
    Code:
    MMatrixws.Range(CompCopyRng(j), MMatrixws.Range(UserformStr(i) & "65536").End(xlUp)).Copy

  5. #5
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Rutime Error 1004

    what are the values (contents) of
    compcopyrange and userformstr arrays?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  6. #6

    Thread Starter
    Member
    Join Date
    May 2009
    Posts
    49

    Re: Rutime Error 1004

    CompCopyRng(0) = "OECtx.Text & FirstRow.Text"

    When i Removed the Quotes it seams to work fine.

    so it is looks like this now
    CompCopyRng(0) = OECtx.Text & FirstRow.Text

  7. #7
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: [RESOLVED] Rutime Error 1004

    that would make sense
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

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



Click Here to Expand Forum to Full Width