Home VBA .Range "Object Required"
Reply: 1

VBA .Range "Object Required"

Heather
1#
Heather Published in 2018-02-14 14:06:47Z

I've looked into this for the past hour or so and can't figure it out.

Sub Paste1()
    Dim NextRow As Range
    Set NextRow = Range("A" & Sheets("AMCurrent").UsedRange.Rows.Count + 1)
    AMPaste.Range("A3:F3").Copy
    AMCurrent.Activate
    NextRow.PasteSpecial Paste:=xlValues, Transpose:=False
    Application.CutCopyMode = False
    Set NextRow = Nothing
End Sub

Getting "object error" on row 4, "AMPaste.Range("A3:F3").Copy". Unsure what to do.

Any help would be appreciated.

Thank you.

Xabier
2#
Xabier Reply to 2018-02-14 14:14:24Z

I'm assuming you didn't declare your Worksheets, and that you used their name instead of Sheets("SheetName"), but I believe this could be your solution:

 Sub Paste1()
    Dim NextRow As Long
    Dim wsPaste As Worksheet: Set wsPaste = Sheets("AMPaste")
    Dim wsCurrent As Worksheet: Set wsCurrent = Sheets("AMCurrent")

    NextRow = wsCurrent.Cells(wsCurrent.Rows.Count, "A").End(xlUp).Row + 1
    wsPaste.Range("A3:F3").Copy
    wsCurrent.Range("A" & NextRow).PasteSpecial Paste:=xlValues, Transpose:=False
    Application.CutCopyMode = False

End Sub
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.375821 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO