Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to Determine if column of certain rows in a text file has data?

I am aware that Excel VBA is able to copy text files line by line.

However, is it possible to test that certain columns in the text file
has information and to store that data(1) in a variable.
Thereafter, on another line, get the data(2) and print both data(1)
and data(2) on one line in an output text file.

eg:

Original Aging Text File has

Cus No Customer Name Invoice No Total Current 1 Mth
10001 ABC Shoe Shop Pte Ltd
A1000101 100.00 100.00
A1000102 200.00 200.00

New Output Aging Text File (Or directly to Excel)

Cust No Customer Name Invoice No Total Current 1 Mth
10001 ABC Shoe Shop Pte Ltd A1000101 100.00 100.00
10001 ABC Shoe Shop Pte Ltd A1000102 200.00 200.00

Thanks in Advance
Tony S
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default How to Determine if column of certain rows in a text file has data

its certainly possible, but to a large degree it depends on how the data is
saved. Is it a CSV file? tab separated or space.
The important thing is how to identify a customer number as the "start" of a
block.
Looks like the customer number is numeric, while a continuation, as per your
example is textual. So you could test for that

DO UNTIL textfile.EOF
' read in a line
text =textfile.ReadLine
' get the first space
firstgap = instr(2,text," ")
' get the first word
firstword = left(text,firstgap-1)
if ISNUMERIC(firstword) THEN
' its a new customer
custnumber = firstword
custname = getsecodword
invoice = getinvoice
' etc
else
' its more records
getinvoice
etc
End If
' write the data to a new file/worksheet

' now for the next line
LOOP





"Tony" wrote:

I am aware that Excel VBA is able to copy text files line by line.

However, is it possible to test that certain columns in the text file
has information and to store that data(1) in a variable.
Thereafter, on another line, get the data(2) and print both data(1)
and data(2) on one line in an output text file.

eg:

Original Aging Text File has

Cus No Customer Name Invoice No Total Current 1 Mth
10001 ABC Shoe Shop Pte Ltd
A1000101 100.00 100.00
A1000102 200.00 200.00

New Output Aging Text File (Or directly to Excel)

Cust No Customer Name Invoice No Total Current 1 Mth
10001 ABC Shoe Shop Pte Ltd A1000101 100.00 100.00
10001 ABC Shoe Shop Pte Ltd A1000102 200.00 200.00

Thanks in Advance
Tony S

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
Sectioning rows of text based on value of associated data column Carmen Bauer Excel Worksheet Functions 1 January 17th 09 01:41 AM
Rows of Data in Excel to Text File Russell Excel Discussion (Misc queries) 2 August 29th 07 05:10 PM
text data in one column many rows to many columns one row MoniqueL Excel Discussion (Misc queries) 1 March 14th 06 10:17 AM
how to import data from text file which has more 70k rows ? meh Excel Programming 1 January 16th 04 05:14 PM
macro to determine colour of text in rows [email protected] Excel Programming 2 January 12th 04 11:36 PM


All times are GMT +1. The time now is 02:16 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"