Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Deleting Rows

What would be the proper code to remove all rows in a workbook except the
rows that counta = 11 or counta = 4. Thank you in advance


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Deleting Rows

Dim lastrow as Long, i as long
dim cnt as long
lastrow = cells(rows.count,1).End(xlup).row
for i = Lastrow to 1 step - 1
cnt = application.CountA(cells(i,1).EntireRow)
if cnt < 11 and cnt < 4 then
cells(i,1).Entirerow.Delete
end if
Next

--
Regards,
Tom Ogilvy

"David Bateman" wrote in message
...
What would be the proper code to remove all rows in a workbook except the
rows that counta = 11 or counta = 4. Thank you in advance




  #3   Report Post  
Posted to microsoft.public.excel.programming
KL KL is offline
external usenet poster
 
Posts: 201
Default Deleting Rows

or I guess:

Dim LastRow As Long, i As Long
LastRow = Cells(Rows.Count, 1).End(xlUp).Row
For i = LastRow To 1 Step -1
Select Case Application.CountA(Rows(i))
Case 11, 4
Case Else: Rows(i).Delete
End Select
Next i

Regards,
KL

"Tom Ogilvy" wrote in message
...
Dim lastrow as Long, i as long
dim cnt as long
lastrow = cells(rows.count,1).End(xlup).row
for i = Lastrow to 1 step - 1
cnt = application.CountA(cells(i,1).EntireRow)
if cnt < 11 and cnt < 4 then
cells(i,1).Entirerow.Delete
end if
Next

--
Regards,
Tom Ogilvy

"David Bateman" wrote in message
...
What would be the proper code to remove all rows in a workbook except the
rows that counta = 11 or counta = 4. Thank you in advance






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
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Links and Linking in Excel 1 November 13th 08 08:44 AM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Setting up and Configuration of Excel 1 November 12th 08 06:05 PM
Macro for deleting rows and serialising the remaing rows Srinivasulu Bhattaram Excel Worksheet Functions 1 November 12th 08 01:39 PM
Help!! I have problem deleting 2500 rows of filtered rows!!!! shirley_kee Excel Discussion (Misc queries) 1 January 12th 06 03:24 AM
deleting hidden rows so i can print only the rows showing?????? jenn Excel Worksheet Functions 0 October 6th 05 04:05 PM


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

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

About Us

"It's about Microsoft Excel"