VB Script to remove row

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a vb script written to just open a workbook and remove the first row.
I need it to remove the row not just delete the cell contents. here is the
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

I keep getting an error on line 5 char 24. Is there a different tag I should
be using?
 
Try this

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


--

HTH

RP
(remove nothere from the email address if mailing direct)
 
Try this

Change the sheet name

objWorkbook.Sheets("sheet1").Rows("1:1").Delete
 
Thanks to both of you. Both ways worked like a charm. I appreciate the
repsonses.
 

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

Back
Top