AllExperts > VB Script 
Search      
VB Script
Volunteer
Answers to thousands of questions
 Home · More VB Script Questions · Answer Library  · Encyclopedia ·
More VB Script Answers
Question Library

Ask a question about VB Script
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Subbu
Expertise
I can answer VB Script questions which are related to Visual Basic / VBA / QTP Scripts.

Experience
8 Years

Education/Credentials
Master of Computer Applications

Awards and Honors
Established Member from QA Forums and Brainbench certification

 
   

You are here:  Experts > Computing/Technology > Basic > VB Script > VB script for excel

VB Script - VB script for excel


Expert: Subbu - 5/21/2009

Question
QUESTION: How to change the name of the existing worksheet in excel

Eg: sheet1 to data1

how to insert a new row in the existing excel sheet.
and how to delete an empty row in the excel sheet

ANSWER: Sreedhar

How to change the name of the existing worksheet in excel:

Double click on sheet1 and press Del button and type what ever you want as sheet name

how to insert a new row in the existing excel sheet:
select the Row number where you want insert a new row and click right mouse button and select Insert Option.


and how to delete an empty row in the excel sheet:

Same as insert row, it means select that row which you want to be deleted and click right mouse button and select Delete option.

You can also do them using Macro code if you have a ton of them.

Subbu.

---------- FOLLOW-UP ----------

QUESTION: HI Subbu,

Thanks for spending time in replying me..

sorry for not asking the question in detailed..

Currently iam working with QTP so i have to do coding in VB Script.
Iam able to write the code as follows

set xlobj = createobject("excel.application")
set wrkbook = xlobj.workbooks.open("path of the xls sheet")
set wrksht = xlobj.worksheets("sheet name to interact with")
wrksht.rows(3).delete--> means we can delete the pirticular cell in excel sheet
*but i want to insert a new cell in the selected sheet

If possible please send me the answer.If not please let me know the right place to post the VB Script questions to get clarified..

Thanks in advance
sridhar

Answer
I was thought the same that question is incorrect and you were trying to insert cells using VBA / qtp code.  Here is your code:

wrkst.rows(3).delete means it delete entire 3rd row.
wrkst.rows(2).insert means it insert entire 2nd row.
Use .Cells(row,col) to insert or delete particular cell.
Example: wrksht.cells(3,1).insert 'It insert A3 cell in excel file.
wrksht.cells(2,2).delete 'It deletes B2 cell

Let me know if you have further questions.


Subbu.

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.