Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Bring filtered data from another file | Excel Discussion (Misc queries) | |||
Bring filtered data from another file | Excel Discussion (Misc queries) | |||
Return filtered values into report worksheet based on filtered valueon the data worksheet | Excel Worksheet Functions | |||
MS2007 - deleting filtered data, deletes non-visible data too | Excel Discussion (Misc queries) | |||
How sort filtered file. | New Users to Excel |