Help. Selecting start row for text file import VBA

tigersden

Board Regular
Joined
Oct 5, 2005
Messages
91
Hi,
I have managed to import a text file & then delete the first row imported as it contains the query used to produced the original file & unfirtunately I cannot get this removed at source.
But I am stuck trying to import a second file which needs to start at the next row down from the previous import.
I need help with
1) Finding the next row to start import & passing this to the the sub see bold text below:
With ActiveSheet.QueryTables.Add(Connection:="TEXT;H:\Work\EROS\TestData\Oct05.txt", Destination:=Range("A1"))
2) When importing has finished go the the first row (Used in above) & delete it.

Any ideas??
 

acw

MrExcel MVP
Joined
Feb 13, 2004
Messages
4,814
Hi

Assuming that the first file has already been imported and the header row deleted, try something like

nextrow = cells(rows.count,"A").end(xlup).offset(1,0).row
With ActiveSheet.QueryTables.Add(Connection:="TEXT;H:\Work\EROS\TestData\Oct05.txt", Destination:= Range("A" & nextrow))
...
end with

cells(nextrow,1).entirerow.delete

HTH

Tony
 

tigersden

Board Regular
Joined
Oct 5, 2005
Messages
91
Thanks Tony.
I did manage to get it to work eventually but will look at your method as it appears more efficient.
Thanks once again
Tim
 

Forum statistics

Threads
1,077,783
Messages
5,336,306
Members
399,074
Latest member
rlong98

Some videos you may like

This Week's Hot Topics

Top