Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Problem Deleting all rows from List Object

When I run the subroutine below I get the following error after some rows
are deleted. I can restart the code and it will run for a few rows and error
again. Could someone please tell me what I am doing wrong?
TIA
Dean
---------------------------
Error
---------------------------
1004Application-defined or object-defined error
---------------------------
OK
---------------------------


Sub DeleteAllListRows()
Dim wrksht As Worksheet
Dim objListObj As ListObject
Dim objListRows As ListRows
Dim objLR As ListRow

On Error GoTo ErrorHandler

Set wrksht = ActiveWorkbook.Worksheets("Drawings")
Set objListObj = wrksht.ListObjects(1)
Set objListRows = objListObj.ListRows

For Each objLR In objListRows
If objListRows.Count 0 Then
objLR.Delete
End If
Next


Exit Sub
ErrorHandler:
MsgBox Err.Number & Err.Description, vbOKOnly, "Error"

Resume Next

End Sub


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 258
Default Problem Deleting all rows from List Object

Hi Dean,

change this:
For Each objLR In objListRows
If objListRows.Count 0 Then
objLR.Delete
End If
Next

with a loop:

for i=1 to objListRows.count

....do what you want

next i

Regards,

Ivan

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help!! I have problem deleting 2500 rows of filtered rows!!!! shirley_kee Excel Discussion (Misc queries) 1 January 12th 06 03:24 AM
Help!!! I have problem deleting 2500 rows of filtered rows shirley_kee[_2_] Excel Programming 1 January 12th 06 03:15 AM
Deleting Rows Automatically using a Text File List mirdonamy Excel Discussion (Misc queries) 9 January 11th 06 11:11 PM
Problem occur in sum function while deleting the rows Ellis Yu Excel Worksheet Functions 0 October 26th 05 02:50 AM
Deleting rows from list of files italia Excel Programming 9 January 10th 05 06:01 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"