Error using offset

J

J.W. Aldridge

compile error:
invalid or unqualified reference

Sub APPLES()
'COPY OP FNAME & PASTE

Sheets("Correct").Select
Range("g2").Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
Sheets("Errors").Select
Range("AA6500").Select
Selection.End(xlUp).Select
.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone,
SkipBlanks:= _
False, Transpose:=False
Application.CutCopyMode = False
End Sub
 
C

Chip Pearson

The line
.Offset(1, 0).Select

needs to qualified by a preceding With statement. Eg.,

With Selection
.Offset(1,0).Select
End With

or just

Selection.Offset(1,0).Select

Cordially,
Chip Pearson
Microsoft Most Valuable Professional,
Excel, 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
 
J

joel

Your error was caused by the line being too long and you didn't use
line continuation character (underscore) to joingn the line. Here i
how I would write the macro


Sub APPLES()
'COPY OP FNAME & PASTE

With Sheets("Correct")
LastRow = .Range("G2").End(xlDown).Row
.Range("G2:G" & LastRow).Copy
End With

With Sheets("Errors")
LastRow = .Range("AA" & Rows.Count).End(xlUp).Row
Newrow = LastRow + 1
.Range("AA" & Newrow).PasteSpecial _
Paste:=xlValues
End With
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top