Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
What I'm looking to do is write to a
file the specific rows I sorted on. One record per line. I know, it sounds re-dundant, but it's part of a larger picture. fyi. the column value for the records I need write is x. if there's an x in that comlumn for a record, write the record to a text file. Now, since it's been over a decade since I last coded, I can't figure out to start with what kind of loop to do. For, while, etc. And how I read from the Excel spreadsheet. Thanks in advance. -Michael Psuedo code: For each row with column "T"="x" Do Write row to c:\sorted_data.txt End For |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Dim iLastRow As Long Dim i As Long Open "TESTFILE" For Output As #1 iLastRow = Cells(Rows.Count, "A").End(xlUp).Row For i = 1 To iLastRow If Cells(i, "A").Value = "x" Then Print #1, Rows(i).EntireRow End If Next i Close #1 as an example -- HTH Bob Phillips wrote in message oups.com... What I'm looking to do is write to a file the specific rows I sorted on. One record per line. I know, it sounds re-dundant, but it's part of a larger picture. fyi. the column value for the records I need write is x. if there's an x in that comlumn for a record, write the record to a text file. Now, since it's been over a decade since I last coded, I can't figure out to start with what kind of loop to do. For, while, etc. And how I read from the Excel spreadsheet. Thanks in advance. -Michael Psuedo code: For each row with column "T"="x" Do Write row to c:\sorted_data.txt End For |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() This line causes this error -- Run Time Err 13: Type Mismatch Print #1, Rows(i).EntireRow "Bob Phillips" wrote: Dim iLastRow As Long Dim i As Long Open "TESTFILE" For Output As #1 iLastRow = Cells(Rows.Count, "A").End(xlUp).Row For i = 1 To iLastRow If Cells(i, "A").Value = "x" Then Print #1, Rows(i).EntireRow End If Next i Close #1 as an example -- HTH Bob Phillips wrote in message oups.com... What I'm looking to do is write to a file the specific rows I sorted on. One record per line. I know, it sounds re-dundant, but it's part of a larger picture. fyi. the column value for the records I need write is x. if there's an x in that comlumn for a record, write the record to a text file. Now, since it's been over a decade since I last coded, I can't figure out to start with what kind of loop to do. For, while, etc. And how I read from the Excel spreadsheet. Thanks in advance. -Michael Psuedo code: For each row with column "T"="x" Do Write row to c:\sorted_data.txt End For |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry, my mistake. Try this instead
Dim iLastRow As Long Dim iLastCol As Long Dim i As Long, j As Long Open "TESTFILE" For Output As #1 iLastRow = Cells(Rows.Count, "A").End(xlUp).Row For i = 1 To iLastRow If Cells(i, "A").Value = "x" Then ary = Rows(i) For j = 1 To Cells(i, Columns.Count).End(xlToLeft).Column - 1 Print #1, Cells(i, j), Next j Print #1, Cells(i, j) End If Next i Close #1 -- HTH Bob Phillips "Access101" wrote in message ... This line causes this error -- Run Time Err 13: Type Mismatch Print #1, Rows(i).EntireRow "Bob Phillips" wrote: Dim iLastRow As Long Dim i As Long Open "TESTFILE" For Output As #1 iLastRow = Cells(Rows.Count, "A").End(xlUp).Row For i = 1 To iLastRow If Cells(i, "A").Value = "x" Then Print #1, Rows(i).EntireRow End If Next i Close #1 as an example -- HTH Bob Phillips wrote in message oups.com... What I'm looking to do is write to a file the specific rows I sorted on. One record per line. I know, it sounds re-dundant, but it's part of a larger picture. fyi. the column value for the records I need write is x. if there's an x in that comlumn for a record, write the record to a text file. Now, since it's been over a decade since I last coded, I can't figure out to start with what kind of loop to do. For, while, etc. And how I read from the Excel spreadsheet. Thanks in advance. -Michael Psuedo code: For each row with column "T"="x" Do Write row to c:\sorted_data.txt End For |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel Macro Looping Helps | Excel Discussion (Misc queries) | |||
Looping through Excel Applications | Excel Programming | |||
Looping with Excel Forms | Excel Programming | |||
Excel VBA - Help looping through all but 2 workbooks | Excel Programming | |||
Excel VBA-Looping through Multiselection | Excel Programming |