Login | |
|
 |
RE: Excel and vbs - 12/17/2007 7:24:43 PM
|
|
 |
|
| |
Stefgr
Posts: 24
Score: 0
Joined: 11/27/2007
Status: offline
|
It worked Great Thank you very much !!! u use if ... and .. great i didn't even pass my mind thank you. And a last one if yu can help i have read some articles but i can;t even do it work. So far we have the code : 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 'Range = ex.ActiveSheet.Range("A:B").Select For I = 1 To ex.ActiveSheet.UsedRange.Rows.Count If ex.ActiveSheet.Range("A" & I).Value = "Surname" _ And ex.ActiveSheet.Range("B" & I).Value = "Name" Then ID = ex.ActiveSheet.Range("C" & I).Value objfile.WriteLine ID End If Next End With objFile.Close ex.Quit WScript.Quit that check A column /cell+ B column/cell and paste the info the C column/cell Now if we have an excel like A column (cell A1) surname, B column (cell B1) name , C column (cell C1) info1. A column (Cell A2) nothing, B column (Cell B2) nothing, C column (C2) some info more about the person above A column (cell A3) surname, B column (cell B3) name, C column (cell C3) info2. A column (Cell A4) nothing, B column (Cell B4) nothing, C column (C4) some info more about the person above A column (Cell A5) nothing, B column (Cell B5) nothing, C column (C5) some info more about the person above ...etc... The Excel might be like this : http://img409.imageshack.us/my.php?image=excelbp8.jpg The problem is how we can make the code so it read the surname and name and past the info of the cells (like the C1 + C2) ? And in the other example the info of (C3+C4+C5) and etc. If we put an id at start at Cell A (1,2,3,4,....) then surname and then name and then info. It will help ? But how it will understand what to copy to the file? Thank you
< Message edited by Stefgr -- 12/17/2007 7:51:15 PM >
|
|
| |
|
|
|
 |
RE: Excel and vbs - 12/18/2007 9:29:42 AM
|
|
 |
|
| |
ebgreen
Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
|
Sorry to be a pain, but could you export it as a csv, open the csv in notepad then copy and paste that into a post? I just want to be sure that I am working with the same data that you are.
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
 |
RE: Excel and vbs - 12/18/2007 9:40:24 AM
|
|
 |
|
| |
morpheus83uk
Posts: 274
Score: 0
Joined: 8/21/2006
Status: offline
|
No problem... here you go.. 1,Surname,Name,Course Name,1 2,,,Course Name,2 3,,,Course Name,3 4,,,Course Name,4 5,,,Course Name,5 6,,,Course Name,6 7,,,Course Name,7 8,,,Course Name,8 9,some,other name,Course Name,9 10,,,Course Name,10 11,some,other name,Course Name,11 12,some,other name,Course Name,12 13,,,Course Name,13 14,,,Course Name,14 15,,,Course Name,15 16,Surname,Name,Course Name,16 17,Surname,Name,Course Name,17 18,Surname,Name,Course Name,18 19,Surname,Name,Course Name,19 20,Surname,Name,Course Name,20 21,Surname,Name,Course Name,21 22,,,Course Name,22 23,,,Course Name,23 24,,,Course Name,24 25,,,Course Name,25 26,Surname,Name,Course Name,26 27,Surname,Name,Course Name,27 28,Surname,Name,Course Name,28 29,Surname,Name,Course Name,29 30,Surname,Name,Course Name,30 Many Thanks James
|
|
| |
|
|
|
 |
RE: Excel and vbs - 12/18/2007 9:50:43 AM
|
|
 |
|
| |
ebgreen
Posts: 4613
Score: 31
Joined: 7/12/2005
Status: offline
|
Ok, I am confused as to why you say you should get 1-8 and 16-30. For instance 1 is: 1,Surname,Name,Course Name,1 but 2 is: 2,,,Course Name,2 So 1 has Surname and 2 does not. They would max different criteria so why would they both be in the result?
_____________________________
"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm http://www.visualbasicscript.com/m_47117/tm.htm
|
|
| |
|
|
|
|
|