-
Jan 1st, 2010, 11:25 AM
#1
Thread Starter
Member
[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
-
Jan 1st, 2010, 02:35 PM
#2
Thread Starter
Member
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
-
Jan 1st, 2010, 03:44 PM
#3
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
-
Jan 1st, 2010, 05:32 PM
#4
Thread Starter
Member
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
-
Jan 2nd, 2010, 02:44 AM
#5
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
-
Jan 2nd, 2010, 07:21 AM
#6
Thread Starter
Member
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
-
Jan 2nd, 2010, 04:21 PM
#7
Re: [RESOLVED] Rutime Error 1004
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|