Login | |
|
 |
RE: Excel and vbs - 12/17/2007 12:33:15 AM
|
|
 |
|
| |
Stefgr
Posts: 24
Score: 0
Joined: 11/27/2007
Status: offline
|
GReat Thank you very much this script worked perfectly :) I have some other questions more difficult if you can help me . We have this script : Set ObjFSO = CreateObject("Scripting.FileSystemObject") Const ForWriting = 2 Set objFile = objFSO.OpenTextFile("c:\test.txt", ForWriting, True) Dim ex, I, ID Set ex = CreateObject("Excel.Application") ex.Workbooks.Open "C:\Log.xls" 'Open file With ex.ActiveSheet For I = 1 To ex.ActiveSheet.UsedRange.Rows.Count If ex.ActiveSheet.Range("A" & I).Value = "2" Then ID = ex.ActiveSheet.Range("B" & I).Value objfile.WriteLine ID End If Next End With objfile.Close ex.Quit WScript.Quit This Script Check Log.xls column A to search and find the number 2. If it finds it , it writes the info of column B in a test.txt file. If we have an excel A column the surname , B column the name and we want to write the column C into a file. But We are searching with a surname name method. I should be like this ? : Set ObjFSO = CreateObject("Scripting.FileSystemObject") Const ForWriting = 2 Set objFile = objFSO.OpenTextFile("c:\test.txt", ForWriting, True) Dim ex, I, ID Set ex = CreateObject("Excel.Application") ex.Workbooks.Open "C:\Log.xls" 'Open file With ex.ActiveSheet For I = 1 To ex.ActiveSheet.UsedRange.Rows.Count If ex.ActiveSheet.Range("A"+"B" & I).Value = "surname name" Then <----Check This ID = ex.ActiveSheet.Range("C" & I).Value objfile.WriteLine ID End If Next End With objfile.Close ex.Quit WScript.Quit
|
|
| |
|
|
|
|
|