Hello Community,
I was wondering if there is a way to replace a cell value from one excel spreadsheet and save it as another spreadsheet but with the replaced cell value.

Please Help

Recommended Answers

All 2 Replies

It's been a while since I did this from vbScript but this works. Save this code in sampleapp.vbs and create a test widget.xls file to play with.

set xls = CreateObject("Excel.Application")
xls.WorkBooks.Open "d:\script\dani\widget.xls"

With xls.WorkBooks(1).WorkSheets(1)
    .Cells(2,1) = "Malcolm"
    .Cells(2,2) = "Delarge"
    .Cells(2,3) = 855321
End With

xls.WorkBooks(1).SaveAs "d:\script\dani\widget2.xls"
xls.Quit

quick note - if you get errors while playing you may end up with one or more Excel.exe tasks running. Just use task manager to kill them. Personally, I use pskill.exe (free sysinternals suite app)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.