ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Delete method of Range class failed (https://www.excelbanter.com/excel-programming/368092-delete-method-range-class-failed.html)

dan_coder

Delete method of Range class failed
 

Hi guys

I have a program written in VB.Net that manipulate an XLS file usin
VBA. I have to delete some lines:

ows.Range("119.190").Delete("Shift:=" & -4162)

-4162 is the real value of xlUp

It raise me this exeption:

Delete method of Range class failed

Previously, I tried this:

ows.Select("119.190")
oEx.selection").Delete("Shift:=" & -4162)

The problem persist.

Any idea?

Thank you in advance

--
dan_code
-----------------------------------------------------------------------
dan_coder's Profile: http://www.excelforum.com/member.php...fo&userid=3668
View this thread: http://www.excelforum.com/showthread.php?threadid=56418


NickHK

Delete method of Range class failed
 
If you are using early binding, you can use xlShiftUp.
But shouldn't the Range be written as Range("119:190").
Also, Shift:= is a named argument and as such should not be in quotes, as
you are really passing on the number -4162, not the string <"Shift:="
& -4162.
A further point, the brackets after "Delete" should not be there as you are
not using the return value.

Unless these points above are not valid in the .Net environment.

NickHK

"dan_coder" wrote
in message ...

Hi guys

I have a program written in VB.Net that manipulate an XLS file using
VBA. I have to delete some lines:

ows.Range("119.190").Delete("Shift:=" & -4162)

-4162 is the real value of xlUp

It raise me this exeption:

Delete method of Range class failed

Previously, I tried this:

ows.Select("119.190")
oEx.selection").Delete("Shift:=" & -4162)

The problem persist.

Any idea?

Thank you in advance!


--
dan_coder
------------------------------------------------------------------------
dan_coder's Profile:

http://www.excelforum.com/member.php...o&userid=36685
View this thread: http://www.excelforum.com/showthread...hreadid=564187





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

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