Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 425
Default Error using offset

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Error using offset


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



On Mon, 22 Feb 2010 13:43:45 -0800 (PST), "J.W. Aldridge"
wrote:

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Error using offset


Your error was caused by the line being too long and you didn't use a
line continuation character (underscore) to joingn the line. Here is
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


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=181580

Microsoft Office Help

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
OFFSET and LOOKUP Error Jim Excel Worksheet Functions 2 March 15th 10 08:42 PM
Error in Function OFFSET Daniel Utsch[_2_] Excel Worksheet Functions 5 January 29th 09 04:50 PM
Offset/match returns #value error Geoff Excel Worksheet Functions 8 May 7th 08 03:56 AM
error: ActiveCell.Offset(0, -1).Select = Application-defined or object-defined error -[::::Shamran::::]- Excel Programming 7 June 7th 05 02:14 PM
Range Offset Error NetWave128[_7_] Excel Programming 2 November 5th 04 11:15 PM


All times are GMT +1. The time now is 06:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"