Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
A Macro that gets data from an ASCII file
All,
I would like to write a Macro that does the following: 1. Opens an ASCII file (e.g. a *.txt or *.raw file) 2. Copies the data from the ASCII file into the Excel file. Every line from the ASCII line should be inserted into a new row 3. closes the file Could someone tell me how to do this? Best, |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
A Macro that gets data from an ASCII file
Go to TOOLS|Macro
Start recording a macro Choose name Choode File|Open Select your file Make your choices in the import wizard Stop recording your macro Tools|Macro|Macros Select your macro and click EDIT You have your macro Now you can adapt it "Boris" wrote: All, I would like to write a Macro that does the following: 1. Opens an ASCII file (e.g. a *.txt or *.raw file) 2. Copies the data from the ASCII file into the Excel file. Every line from the ASCII line should be inserted into a new row 3. closes the file Could someone tell me how to do this? Best, |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
A Macro that gets data from an ASCII file
Try some code like the following:
Sub AAA() Dim FName As Variant Dim FNum As Integer Dim LineRead As String Dim R As Range Set R = ActiveSheet.Range("A1") '<<< CHANGE START CELL FName = Application.GetOpenFilename( _ "Text Files (*.txt;*.raw),*.txt;*.raw") If FName = False Then ' no file selected Exit Sub End If FNum = FreeFile() Open FName For Input Access Read As #FNum Do Until EOF(FNum) Line Input #FNum, LineRead R.Value = LineRead Set R = R(2, 1) Loop Close #FNum End Sub Cordially, Chip Pearson Microsoft Most Valuable Professional Excel Product Group Pearson Software Consulting, LLC www.cpearson.com (email on web site) On Fri, 31 Oct 2008 08:45:00 -0700, Boris wrote: All, I would like to write a Macro that does the following: 1. Opens an ASCII file (e.g. a *.txt or *.raw file) 2. Copies the data from the ASCII file into the Excel file. Every line from the ASCII line should be inserted into a new row 3. closes the file Could someone tell me how to do this? Best, |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Merge data from an ascii file into a Word doc | Excel Discussion (Misc queries) | |||
using data from ascii file? | Excel Discussion (Misc queries) | |||
Lookup & return data from ascii text file | Excel Programming | |||
Read data from ascii file | Excel Programming | |||
Selective read data from ascii file | Excel Programming |