PC Review


Reply
Thread Tools Rate Thread

Delete Method Of Range Class Failed Error

 
 
New Member
Join Date: Aug 2010
Posts: 2
 
      10th Aug 2010
I am using VB language behind excel to code. When I hit delete button on excel sheet, I get following error.

DELETE METHOD OF RANGE CLASS FAILED ERROR, when fol
lowing line encounters: ActiveSheet.Rows(Rnum).EntireRow.DELETE

My code:


Public KintanaNo As String
Public serno As Integer
Public Rnum As Integer
Public totalrows As Integer

Private Sub btndelete_Click()
Dim i As Integer
KintanaNo = Trim(txtkintana.Text)
serno = Trim(txtserial.Text)
totalrows = ActiveSheet.UsedRange.Rows.Count
Rnum = 1

For i = 1 To totalrows Step 1
If (ActiveSheet.Cells(Rnum, 1).Value) = serno And (ActiveSheet.Cells(Rnum, 2).Value) = KintanaNo Then
ActiveSheet.Rows(Rnum).EntireRow.DELETE
End If
Rnum = Rnum + 1
Next i



Can anyone please tell what is alternative method to avoid this error?
 
Reply With Quote
 
 
 
 
New Member
Join Date: Aug 2010
Posts: 2
 
      11th Aug 2010
I got the solution.

The sheet should be unprotected at the start of the code .

ActiveSheet.Unprotect Password:="Wiccvv"


At the end of the code, again protect the sheet like this:-

ActiveSheet.protect Password:="Wiccvv"
 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete method of Range class failed dan_coder Microsoft Excel Programming 1 24th Jul 2006 10:16 AM
"delete method of range class failed Kathy Goldie Microsoft Excel Programming 2 19th May 2005 06:45 PM
Delete method of Range class failed - HELP! richilli Microsoft VB .NET 1 22nd Oct 2004 12:31 AM
Delete method of Range class failed - HELP!!! richilli Microsoft Excel Programming 1 20th Oct 2004 06:24 PM
runtime error '1004' delete Method of Range Class Failed Jack Microsoft Excel Programming 3 14th Apr 2004 08:08 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:46 PM.