- Joined
- Aug 10, 2010
- Messages
- 2
- Reaction score
- 0
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?
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?