Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default txt file from filtered data

I have a worksheet that has 6 columns. The number of rows can vary. I need
to filter the worksheet on 3 of the columns to narrow the data down to what I
need to extract. Then I need to create a text file using the filtered data
so that cells A1, B1, & C1 are on a line and then D1, E1, & F1 are on the
next line. I need to repeat this in the text file for each row in the
filtered worksheet. Is this possible?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default txt file from filtered data

Text file is ambibuous. Do you want comma delimited, tab delimited, fixed
column?

Do you just need to be prompted with
Use Autofilter, then build the textfile using low level file io

http://www.applecore99.com/gen/gen029.asp

or do you need someone to put up example code?

--
Regards,
Tom Ogilvy

"Kevin R" wrote in message
...
I have a worksheet that has 6 columns. The number of rows can vary. I

need
to filter the worksheet on 3 of the columns to narrow the data down to

what I
need to extract. Then I need to create a text file using the filtered

data
so that cells A1, B1, & C1 are on a line and then D1, E1, & F1 are on the
next line. I need to repeat this in the text file for each row in the
filtered worksheet. Is this possible?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default txt file from filtered data

Do you need to actually filter the sheet (and leave it filtered) or is the
filtering just to find the data to extract? You don't really need to filter
since you can have your code check the conditions you need. Without knowing
more, I can only outline a procedu

Sub ExtractData()

Dim DataRange as Range, ThisRow as Integer, OutputStr as String

Open "C:\EXAMPLE\Mytextfile.txt" For Append as #1 ' or, For Output

Set DataRange=Sheets("DataSheetName").Range("DataRange ")
For ThisRow = 1 to DataRange.Rows.Count
' Now read the data, line by line, using the Offset method to find the cell
you want to check, e.g:
If DataRange.Offset(ThisRow-1,2) = ??? _ ' This checks the 3rd column in
your list
Then OutputStr=DataRange.Offset(ThisRow-1,3).Range("A1").Value & "," _
& DataRange.Offset(ThisRow-1,4).Range("A1").Value
' The above creates a comma-delimited entry based on the values in columns 4
& 5
' (Note that .Offset begins with 0 for the current row/column)

Write #1, OutputStr
Next ThisRow

Close #1
End Sub

"Kevin R" wrote:

I have a worksheet that has 6 columns. The number of rows can vary. I need
to filter the worksheet on 3 of the columns to narrow the data down to what I
need to extract. Then I need to create a text file using the filtered data
so that cells A1, B1, & C1 are on a line and then D1, E1, & F1 are on the
next line. I need to repeat this in the text file for each row in the
filtered worksheet. Is this possible?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default txt file from filtered data

I really don't know how or where to begin. Fixed columns would probably work
but I could just separate each cell with a few spaces on each line of the
text file. If I could do some type of autofilter or input box to ask for the
3 criterias to narrow it down to only the data I needed would be good leaving
only the filtered text and deleting everything else. I can use the
autofilter built into Excel if I need to. the main thing is to figure out
how to dump this into the txt file in the format I need with the certain
cells on one line, other cells on the next line, and then insert a blank line
and do it all over again for each remaining row. Thanks.

"Tom Ogilvy" wrote:

Text file is ambibuous. Do you want comma delimited, tab delimited, fixed
column?

Do you just need to be prompted with
Use Autofilter, then build the textfile using low level file io

http://www.applecore99.com/gen/gen029.asp

or do you need someone to put up example code?

--
Regards,
Tom Ogilvy

"Kevin R" wrote in message
...
I have a worksheet that has 6 columns. The number of rows can vary. I

need
to filter the worksheet on 3 of the columns to narrow the data down to

what I
need to extract. Then I need to create a text file using the filtered

data
so that cells A1, B1, & C1 are on a line and then D1, E1, & F1 are on the
next line. I need to repeat this in the text file for each row in the
filtered worksheet. Is this possible?




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default txt file from filtered data

Guess K Dales wants this one, so work with him.

--
Regards,
Tom Ogilvy

"Kevin R" wrote in message
...
I really don't know how or where to begin. Fixed columns would probably

work
but I could just separate each cell with a few spaces on each line of the
text file. If I could do some type of autofilter or input box to ask for

the
3 criterias to narrow it down to only the data I needed would be good

leaving
only the filtered text and deleting everything else. I can use the
autofilter built into Excel if I need to. the main thing is to figure out
how to dump this into the txt file in the format I need with the certain
cells on one line, other cells on the next line, and then insert a blank

line
and do it all over again for each remaining row. Thanks.

"Tom Ogilvy" wrote:

Text file is ambibuous. Do you want comma delimited, tab delimited,

fixed
column?

Do you just need to be prompted with
Use Autofilter, then build the textfile using low level file io

http://www.applecore99.com/gen/gen029.asp

or do you need someone to put up example code?

--
Regards,
Tom Ogilvy

"Kevin R" wrote in message
...
I have a worksheet that has 6 columns. The number of rows can vary.

I
need
to filter the worksheet on 3 of the columns to narrow the data down to

what I
need to extract. Then I need to create a text file using the filtered

data
so that cells A1, B1, & C1 are on a line and then D1, E1, & F1 are on

the
next line. I need to repeat this in the text file for each row in the
filtered worksheet. Is this possible?








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default txt file from filtered data

I guess I don't need to filter it the way I was thinking as long as I can
extract the rows that meet my criteria (status, date, employee). Then I only
need to pull from each of those rows specific cells for the txt file.

"K Dales" wrote:

Do you need to actually filter the sheet (and leave it filtered) or is the
filtering just to find the data to extract? You don't really need to filter
since you can have your code check the conditions you need. Without knowing
more, I can only outline a procedu

Sub ExtractData()

Dim DataRange as Range, ThisRow as Integer, OutputStr as String

Open "C:\EXAMPLE\Mytextfile.txt" For Append as #1 ' or, For Output

Set DataRange=Sheets("DataSheetName").Range("DataRange ")
For ThisRow = 1 to DataRange.Rows.Count
' Now read the data, line by line, using the Offset method to find the cell
you want to check, e.g:
If DataRange.Offset(ThisRow-1,2) = ??? _ ' This checks the 3rd column in
your list
Then OutputStr=DataRange.Offset(ThisRow-1,3).Range("A1").Value & "," _
& DataRange.Offset(ThisRow-1,4).Range("A1").Value
' The above creates a comma-delimited entry based on the values in columns 4
& 5
' (Note that .Offset begins with 0 for the current row/column)

Write #1, OutputStr
Next ThisRow

Close #1
End Sub

"Kevin R" wrote:

I have a worksheet that has 6 columns. The number of rows can vary. I need
to filter the worksheet on 3 of the columns to narrow the data down to what I
need to extract. Then I need to create a text file using the filtered data
so that cells A1, B1, & C1 are on a line and then D1, E1, & F1 are on the
next line. I need to repeat this in the text file for each row in the
filtered worksheet. Is this possible?

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
Bring filtered data from another file CousinExcel Excel Discussion (Misc queries) 0 January 11th 10 12:20 PM
Bring filtered data from another file cousinexcel Excel Discussion (Misc queries) 0 January 11th 10 07:06 AM
Return filtered values into report worksheet based on filtered valueon the data worksheet dicko1 Excel Worksheet Functions 1 April 21st 09 12:27 AM
MS2007 - deleting filtered data, deletes non-visible data too Nita Excel Discussion (Misc queries) 1 December 9th 08 03:42 PM
How sort filtered file. Rao Ratan Singh New Users to Excel 1 December 26th 05 01:54 PM


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