ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VB Script to remove row (https://www.excelbanter.com/excel-programming/316520-vbulletin-script-remove-row.html)

dennis

VB Script to remove row
 
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?

Bob Phillips[_6_]

VB Script to remove row
 
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)


"Dennis" wrote in message
...
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?




Ron de Bruin

VB Script to remove row
 
Try this

Change the sheet name

objWorkbook.Sheets("sheet1").Rows("1:1").Delete

--
Regards Ron de Bruin
http://www.rondebruin.nl


"Dennis" wrote in message ...
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?




dennis

VB Script to remove row
 
Thanks to both of you. Both ways worked like a charm. I appreciate the
repsonses.

"Dennis" wrote:

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?



All times are GMT +1. The time now is 07:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com