VB Script to remove row

G

Guest

I'm trying to write a vb script to open a workbook and just remove the first
row. I need it to remove the row and shift everything up, not just delete the
cell contents.
I recirded a macro of the actcion and then just copied the VB code from the
editor into my script. But when I run it I get and error code 800A0400 at
line 5 char 24.it s the xlup statement. here is the actual script.

Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("C:\book1.xls")
objExcel.Visible = TRUE
Rows("1:1").Select
Selection.Delete Shift:=xlUp
 
A

anilsolipuram

try this


Set objexcel = CreateObject("Excel.Application")
Set objworkbook = objexcel.Workbooks.Open("C:\test.xls")
Set osheet = objworkbook.sheets("sheet1")
objexcel.Visible = True
osheet.Rows("1:1").Select
osheet.Rows("1:1").Delet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top