Simple copy/paste with worksheet variables

jardenp

Active Member
Joined
May 12, 2009
Messages
367
My copy/paste in the "problem line" below is returning a run time error 1004 Method 'Range' of object '_ Worksheet' failed.

What am I doing wrong? I know that the If statement is true for the first time at row 3045 and that the msgboxes return the correct sheet names when I have those lines uncommented.

Thanks!

VBA Code:
    Dim OWS As Worksheet
        Set OWS = ActiveWorkbook.ActiveSheet
        'MsgBox OWS.Name
    RowS("1:1").copy
    Sheets.Add After:=Sheets(Sheets.Count)
    RowS("1:1").Select
    ActiveSheet.Paste
    ActiveSheet.Name = "AR Transaction Lines"
    Dim ARTL As Worksheet
        Set ARTL = ActiveWorkbook.ActiveSheet
        'MsgBox ARTL.Name
       
    Dim r As Integer 'row counter
    Dim s As Integer '"Split" column
        s = 11
    Dim addrow As Integer 'row counter for adding lines on AR sheet
        addrow = 2
           
    For r = 2 To 3047 'OWS.Range("B1000000").End(xlUp).row

        If OWS.Cells(r, s) = "1120 · Accounts Receivable" Then
            OWS.Range(Cells(r, 1), Cells(r, 13)).copy ARTL.Range(Cells(addrow, 1), Cells(addrow, 13)) '****Problem line****
            addrow = addrow + 1
        End If
       
    Next r
 
Last edited by a moderator:

Some videos you may like

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Watch MrExcel Video

Forum statistics

Threads
1,126,999
Messages
5,622,118
Members
415,878
Latest member
jjj12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top