Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 354
Default Merging data

I have a text file that is generated by another app and was wondering what
method would allow me to use its content to populate fields in an Excel
spreadsheet. Similar to merging word w/ access.

If you could point me to an example, website with explanations it would be
greatly appreciated!

Thank you.

Daniel P
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Merging data

Ther are lots of way to drop test into excel.

1) Just paste data into the speadsheet. Then use Data Menu - Text to columns.

2) Data Menu - Import external data - import data

3) The first two methods use similar menu options to break data into each
column such as Commar Delimited. Another metthod is open a text file in VBA
and write your own custom macro to read tthe data and put the data into cells.

4) I've used a fouth method occasionally. I write VBA code which open a
read text file and a write text file. I coverter the read data into CSV
(commar seperated values) and put the data into the write text file. Then I
open the CSV file and excel wil automatticaly put the data into the cells.

"Daniel" wrote:

I have a text file that is generated by another app and was wondering what
method would allow me to use its content to populate fields in an Excel
spreadsheet. Similar to merging word w/ access.

If you could point me to an example, website with explanations it would be
greatly appreciated!

Thank you.

Daniel P

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 354
Default Merging data

I need to do this using vba and completly automate the process. Could you
give me some basic code to get started?

Daniel P





"Joel" wrote:

Ther are lots of way to drop test into excel.

1) Just paste data into the speadsheet. Then use Data Menu - Text to columns.

2) Data Menu - Import external data - import data

3) The first two methods use similar menu options to break data into each
column such as Commar Delimited. Another metthod is open a text file in VBA
and write your own custom macro to read tthe data and put the data into cells.

4) I've used a fouth method occasionally. I write VBA code which open a
read text file and a write text file. I coverter the read data into CSV
(commar seperated values) and put the data into the write text file. Then I
open the CSV file and excel wil automatticaly put the data into the cells.

"Daniel" wrote:

I have a text file that is generated by another app and was wondering what
method would allow me to use its content to populate fields in an Excel
spreadsheet. Similar to merging word w/ access.

If you could point me to an example, website with explanations it would be
greatly appreciated!

Thank you.

Daniel P

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Merging data

It is hard to give code without seeing the data. The 1st thing I would try
is importing the data Using Data - Import External Data - Extternal Data and
see if this reads the data properly.

If this works, the capture the command by go to Tools Macro - Record New
Macro. the recorded macro can be used in your code.


Here is an example of a file that reads and writes text data. It doesn't
have code that puts data into the cells. It simply converts text data into
CSV. Then the CSV can be read into Excel

I'm very good at working with text files and will be glad to give you more
help. You request is very vague and really need to know more about the data
to give you a bettter answer.

Sub Gettext()

Const ForReading = 1, ForWriting = 2, ForAppending = 3
Const MyPath = "C:\temp\"
Const TristateUseDefault = -2, TristateTrue = -1, TristateFalse = 0


Set fsread = CreateObject("Scripting.FileSystemObject")
Set fswrite = CreateObject("Scripting.FileSystemObject")

ReadFileName = "longtext.txt"
WriteFileName = "longtext.csv"


'open files
ReadPathName = MyPath + ReadFileName
Set fread = fsread.GetFile(ReadPathName)
Set tsread = fread.OpenAsTextStream(ForReading, TristateUseDefault)

WritePathName = MyPath + WriteFileName
fswrite.CreateTextFile WritePathName
Set fwrite = fswrite.GetFile(WritePathName)
Set tswrite = fwrite.OpenAsTextStream(ForWriting, TristateUseDefault)


Do While tsread.atendofstream = False

InputLine = tsread.ReadLine


If (InStr(InputLine, "TEXT") 0) Then

If Len(OutputLine) 0 Then
tswrite.WriteLine OutputLine
OutputLine = ""

End If
Else
If Len(OutputLine) 0 Then
OutputLine = OutputLine + "," + InputLine
Else
OutputLine = InputLine
End If
End If

Loop

tswrite.Close
tsread.Close

Exit Sub
End Sub





"Daniel" wrote:

I need to do this using vba and completly automate the process. Could you
give me some basic code to get started?

Daniel P





"Joel" wrote:

Ther are lots of way to drop test into excel.

1) Just paste data into the speadsheet. Then use Data Menu - Text to columns.

2) Data Menu - Import external data - import data

3) The first two methods use similar menu options to break data into each
column such as Commar Delimited. Another metthod is open a text file in VBA
and write your own custom macro to read tthe data and put the data into cells.

4) I've used a fouth method occasionally. I write VBA code which open a
read text file and a write text file. I coverter the read data into CSV
(commar seperated values) and put the data into the write text file. Then I
open the CSV file and excel wil automatticaly put the data into the cells.

"Daniel" wrote:

I have a text file that is generated by another app and was wondering what
method would allow me to use its content to populate fields in an Excel
spreadsheet. Similar to merging word w/ access.

If you could point me to an example, website with explanations it would be
greatly appreciated!

Thank you.

Daniel P

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Merging data from 2 data excel sheets Joe Excel Discussion (Misc queries) 2 November 3rd 09 01:08 PM
Merging multiple columns of data into one column of data Archangel Excel Discussion (Misc queries) 7 February 24th 07 10:02 AM
Should Merging workbooks pick up new data or only edited data? Peggy L. Excel Worksheet Functions 0 January 13th 05 05:31 PM
Merging Data Al Mackay Excel Programming 6 November 17th 03 07:30 AM
Scanning for Duplicate Data in a Column, Merging Data and Finally Removing All Duplicates...? : VB : Excel Programming 2 August 24th 03 02:22 PM


All times are GMT +1. The time now is 02:06 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"