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/316519-vbulletin-script-remove-row.html)

dennis

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



anilsolipuram[_2_]

VB Script to remove row
 

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

--
anilsolipura
-----------------------------------------------------------------------
anilsolipuram's Profile: http://www.excelforum.com/member.php...fo&userid=1627
View this thread: http://www.excelforum.com/showthread.php?threadid=27752



All times are GMT +1. The time now is 12:10 AM.

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