|
-
Jun 1st, 2003, 09:53 PM
#1
Thread Starter
New Member
WSH + VBscript + Excel
Hi,
I'm trying to write a small script that will edit certain cells within an excel file.
So far I have the script opening and closing the file, doing various other bits like logging and so forth.
But the main part of the script is what I'm having problems with.
Esentially I want it to search for a certain value in column 'd'
If that value exists I then want it to delete the data in column 'f' from the same row.
If that makes sense ?
If someone could post some sample code, I would be most grateful.
This is using VBScript btw, not VB itself.
The marco code I get from Excel 2002 dosen't work directly, so I guess it's designed for VB.
-
Jun 2nd, 2003, 04:59 AM
#2
This one seems to work in vbs - actually tested it too! 
VB Code:
Dim objXLAPP
Dim intRowCounter
Set objXLAPP = createobject("Excel.Application")
objXLAPP.displayalerts = false
objXLAPP.Workbooks.Open "C:\TestFile.xls"
For intRowCounter = 1 to objXLAPP.Workbooks(1).Worksheets(1).usedrange.rows.count
If (objXLAPP.Workbooks(1).Worksheets(1).Cells(intRowCounter, 4).value = "2") then
objXLAPP.Workbooks(1).Worksheets(1).Cells(intRowCounter, 6).value = ""
End If
Next
objXLAPP.Workbooks(1).save
objXLAPP.Workbooks(1).close
objXLAPP.displayalerts = true
Set objXLAPP = Nothing
Msgbox "Done!"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|