Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Hucleberry Hound
 
Posts: n/a
Default how to automatically delete non-contiguous rows

Is it possible to define a large data field then delete non-contiguous rows,
like every fifth row, without having to delete each row one at a time?
  #2   Report Post  
Ron de Bruin
 
Posts: n/a
Default

Hi

One way to insert a column with a formula and use
SpecialCells(xlCellTypeBlanks) to delete the rows

Test it on a copy of your workbook

Sub test1()
Application.ScreenUpdating = False
Dim myRows As Long
Range("A1").EntireColumn.Insert
myRows = ActiveSheet.UsedRange.Rows.Count

With Range(Cells(1, 1), Cells(myRows, 1))
.FormulaR1C1 = "=IF(MOD(ROW(),5)=1,""Keep"","""")"
.Value = .Value
End With
Columns("A:A").SpecialCells(xlCellTypeBlanks).Enti reRow.Delete
Range("A1").EntireColumn.Delete
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Hucleberry Hound" wrote in message
...
Is it possible to define a large data field then delete non-contiguous rows,
like every fifth row, without having to delete each row one at a time?



  #3   Report Post  
Junior Member
 
Posts: 1
Default

Hi ron: I just attempted this method, but it returns a Run Time Error 1004. Is there anyway around this using the specialcells method?

Quote:
Originally Posted by Ron de Bruin View Post
Hi

One way to insert a column with a formula and use
SpecialCells(xlCellTypeBlanks) to delete the rows

Test it on a copy of your workbook

Sub test1()
Application.ScreenUpdating = False
Dim myRows As Long
Range("A1").EntireColumn.Insert
myRows = ActiveSheet.UsedRange.Rows.Count

With Range(Cells(1, 1), Cells(myRows, 1))
.FormulaR1C1 = "=IF(MOD(ROW(),5)=1,""Keep"","""")"
.Value = .Value
End With
Columns("A:A").SpecialCells(xlCellTypeBlanks).Enti reRow.Delete
Range("A1").EntireColumn.Delete
Application.ScreenUpdating = True
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Hucleberry Hound" wrote in message
...
Is it possible to define a large data field then delete non-contiguous rows,
like every fifth row, without having to delete each row one at a time?
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
Print titles must be contiguous and complete rows or columns SG Excel Discussion (Misc queries) 2 May 20th 23 07:42 PM
Delete Rows where cells does not meet criteria Danny Excel Worksheet Functions 1 September 12th 05 05:08 PM
Want to delete rows Farooq Sheri Excel Discussion (Misc queries) 6 September 12th 05 12:46 PM
Any way to delete rows that don't contain 'x'? CJSnet Excel Discussion (Misc queries) 10 June 23rd 05 01:28 PM
How to delete rows when List toolbar's "delete" isnt highlighted? Linda Excel Worksheet Functions 1 May 26th 05 08:39 PM


All times are GMT +1. The time now is 05:43 AM.

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"