Steve
Thanks for the code.
It appeared to almost work. My guess is that the 'import table wizard'
needs somehow to be invoked, so nothing ends up happening, cause of
the 'non- .xls file type I guess? So I was not able to try your
LASTROW function(?).
Where the earlier code of Rons' opened an excel workbook and pasted in
data; would there be a way to marry up your code with his to select
the required file from a particular folder, the copy&paste in the
data, in the case of excel files.
Incidentally, with his code;" Range("a2:h600").Copy _ ", only 99
rows were copied in?
Many Thanks
Jon
Better yet, you can use this code to initiate the Open file dialog and pick
the file you want...
Sub OpenMyFile()
' code "borrowed" from the ng
Dim GetFiles As Variant
Dim iFiles As Long
Dim nFiles As Long
GetFiles = Application.GetOpenFilename _
(FileFilter:="Text Files (*.txt),*.txt", _
Title:="Select Files To Open", MultiSelect:=True)
If TypeName(GetFiles) = "Boolean" Then
''' GetFiles is False if GetOpenFileName is Canceled
MsgBox "No Files Selected", vbOKOnly, "Nothing Selected"
End
Else
''' GetFiles is Array of Strings (File Names)
''' File names include Path
nFiles = UBound(GetFiles)
For iFiles = 1 To nFiles
'' List Files in Immediate Window
Debug.Print GetFiles(iFiles)
Next
End If
End Sub
You may have to play with
(FileFilter:="Text Files (*.txt),*.txt", _
(I am not up on ascii type files)
You may not even need that part.
Once open you may automatically be put into the text wizard. Or you may
have
to use Text to Columns in the Data menu. You can record this part and make
it
part of your code.
Than you can use
Dim LASTROW As Long
LASTROW = Cells(Rows.COUNT, "A").End(xlUp).Row
to determine the number of records. Change "A" to the column that
will always have the greatest number of records (if not all columns
have data to the bottom of the file).
Than
Range(Cells(1, 1),Cells(LASTROW, 12)).Copy
to copy. (this copies columns A to L from row 1 to Lastrow)
steve