[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Excel 2000 VBa book--some details reqd.



PureBytes Links

Trading Reference Links

Thanks Ton for the info on importing data from sheets into Metastock.

Here's some VBA for opening multiple text files into Excel using Shift+click
or Ctrl+click.
Thanks to Tom for the assistance in coding "loops"
ChDir = Change Directory   --> enter address of your target folder with the
text files to download
Enter destination workbook and sheet position in 6th last line
I've never tried it to download directly off the internet.

Best regards

Walter
======================

Sub ImportTextFile()
     Dim myFile as Variant
     ChDir "D:\TurtleData\Soybeans"
     myFile = Application.GetOpenFilename("Text
Files,*.txt",MultiSelect:=True)
     if isarray(myFile) then
     for i = lbound(myfile) to ubound(myfile)
      Workbooks.OpenText _
         Filename:=myFile(i), _
         Origin:=xlWindows, _
         StartRow:=1, _
         DataType:=xlDelimited, _
         TextQualifier:=xlDoubleQuote, _
         ConsecutiveDelimiter:=False, _
         Tab:=True, _
         Semicolon:=False, _
         Comma:=True, _
         Space:=False, _
         Other:=False, _
         FieldInfo:=Array(Array(1, 1), _
         Array(2, 1), Array(3, 1), _
         Array(4, 1), Array(5, 1), _
         Array(6, 1), Array(7, 1))
       ActiveSheet.Move _
         Before:=Workbooks("SoyBeans_30YrData.xls").Sheets(2)
     Next i
     else
       msgbox "You hit cancel"
     End if
 End Sub



----- Original Message -----
From: A.J. Maas <anthmaas@xxxxxxxxx>
To: Metastock-List <metastock@xxxxxxxxxxxxx>
Sent: Friday, October 01, 1999 6:38 PM
Subject: Re: Excel 2000 VBa book--some details reqd.


| > PS: How does Metastock handle the importing of price data on multiple
| > worksheets in an Excel workbook. Can I specify a sheet?
|
| The DL's Convert-Tool won't handle multiple worksheets (when in an Excel
workbook),
| unless this workbook is Saved As.........................an Excel
4.0-sheet (a single sheet that
| is then 'automatically' Saved As a 'single' sheet, eg saving as the <at
that time>
| Active-sheet (that sheets name is in the Excel program's top 'blue'
title-bar).
|
| In those (Excel v4.0) days, no workbooks were available yet (single sheets
only).
|
| Regards,
| Ton Maas
| ms-irb@xxxxxxxxxxxxxxxx
| Dismiss the ".nospam" bit (including the dot) when replying and
| note the new address change. Also for my Homepage
| http://home.planet.nl/~anthmaas
|
|
|