Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add one row after end of data

Status
Not open for further replies.

Cordury2

Technical User
Jan 22, 2005
55
US
I am attempting to have the marco go to the end of the data PLUS one row. The current line of code is:

Selection.End(x1Down).Select

Any ideas or thoughts why this is not working?

Thanks
 

Code:
selection.end(xldown).offset(1).select

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
What is not working. Please explain what IS happening? Please describe your data with respect to the original Selection range.

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
I am just attempting to have the marco go to the end of the data in column A plus one row.

Workbooks.Open Filename:="Path"
Workbooks.Open Filename:="Path"
Windows("invagedptcan.DIF").Activate
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Select
Range(Selection, Selection.End(xlToRight)).Select
Selection.Copy
Windows("invagedpt.DIF").Activate
Range("A1").Select
selection.end(xldown).offset(1).select
 
Basically, I am just attempting to copy data from 2 different .dif files and paste the data into a new sheet.
 

Code:
    workbooks("invagedptcan.DIF").Sheets(1).[A1].CurrentRegion.Copy Workbooks("invagedpt.DIF").Sheets(1).[A1].End(xlDown).Offset(1)
could be a different sheet, I dont't know.

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
Place that code after the
selection.end(xldown).offset(1).select
?
 


Substitute for EVERYTHING except the OPEN statements

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
Thanks for all your help, Skip. It is still crapping out though. I just can't get a grasp on VBA.

Well there is always Ditch Digging.
 

1) I'd stay away from the Windows object. Rather reference the workbook and worksheet.

2) I don't know what this is supposed to mean. It does not make sense.
Code:
Workbooks.Open Filename:="Path"
    Workbooks.Open Filename:="Path"
3) substitute the workbook name / sheet tab name instead of the numbers.
Code:
Workbooks.Open Filename:="Path"
    Workbooks.Open Filename:="Path"
    Workbooks(1).Sheets(1).[A1].CurrentRegion.Copy _
    Workbooks(2).Sheets(1).[A1].End(xlDown).Offset(1)
Tell me EXACTLY what is NOT working.


Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
I just typed the word "Path" in my post. The actual code contains the path and file name of each file.

The following line of code is returning the below error:

Workbooks("invagedpt.DIF").Sheets(1).[A1].End(xlDown).Offset (1)

Run Time Error '438'

Object does not support this property or method.
 

Ther is no single line of code that I posted that is
Code:
[red]
Workbooks("invagedpt.DIF").Sheets(1).[A1].End(xlDown).Offset (1)[/red]
however, I DID post this single line of code
Code:
    Workbooks(1).Sheets(1).[A1].CurrentRegion.Copy _
    Workbooks(2).Sheets(1).[A1].End(xlDown).Offset(1)
the UNDERSCORE is essential! It's ALL ONE LINE

Skip,

[glasses] [red]A palindrome gone wrong?[/red]
A man, a plan, a ROOT canal...
PULLEMALL![tongue]
 
In order to be able to select down and to the right use this:

Range(Selection.Address & ":" & Selection.End(xlDown).Address).Select
Range(Selection.Address & ":" & Selection.End(xlToRight).Address).Select

Range has to be defined using selection address...
Fane Duru
 

Skip,Thanks for all of your help and patience. The code was missing the underscore.

FaneDuru - thanks for the tip but I did not to move to the right. I just needed the macro to go to the end of the data plus one row.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top