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??
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,552
Members
449,088
Latest member
davidcom

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top