Print Page | Close Window

VBScript to Delete a Particular row in an EXCELSHE

Printed From: One Stop Testing
Category: Testing Tools @ OneStopTesting
Forum Name: QuickTest Pro @ OneStopTesting
Forum Discription: QuickTest Pro is a fresh approach to automated software and application testing that addresses testing needs of both business analysts and Quality Assurance professionals.
URL: http://forum.onestoptesting.com/forum_posts.asp?TID=7378
Printed Date: 17Nov2024 at 8:53am


Topic: VBScript to Delete a Particular row in an EXCELSHE
Posted By: Mithi25
Subject: VBScript to Delete a Particular row in an EXCELSHE
Date Posted: 25Nov2009 at 10:44pm
We have Excelsheet with following values

A B C
11 lak QTP
22 lax LR
33 laxmi WR
44 lakshmi QC

Set aa = CreateObject("Excel.Application")
Set bb = aa.Workbooks.Open("C:\es.xls")
Set cc = aa.worksheets("Sheet1")
cc.Rows(1).Delete
bb.Save
aa.Workbooks.Close()

Above script deletes first row of excelsheet.

After running the script excelsheet will have following values.

A B C
22 lax LR
33 laxmi WR
44 lakshmi QC

Similarly to delete 3 row(just replace 1 with 3 in the above script).

Set aa = CreateObject("Excel.Application")
Set bb = aa.Workbooks.Open("C:\es.xls")
Set cc = aa.worksheets("Sheet1")
cc.Rows(3).Delete
bb.Save
aa.Workbooks.Close()

-------------
http://www.quick2sms.com - Send Unlimited FREE SMS to Any Mobile Anywhere in INDIA,
Click Here



Print Page | Close Window