![]() |
excel formulae
I want to take out 90% of the rows, in order to have a more workable number
of rows. How do i eliminate rows at random, i.e. not me selecting? |
Try the macro below, which will keep _about_ 10% of the rows - that the nature of randomness ;-)
HTH, Bernie MS Excel MVP Sub Keep10ishPercent() Dim myRows As Long Range("A1").EntireColumn.Insert Range("A1").FormulaR1C1 = _ "=IF(RAND()*10<=1,""Keep"",""Trash"")" myRows = ActiveSheet.UsedRange.Rows.Count Range("A1").Copy Range("A1:A" & myRows) With Range(Range("A1"), Range("A1").End(xlDown)) .Copy .PasteSpecial Paste:=xlValues End With Cells.Select Selection.Sort Key1:=Range("A1"), Order1:=xlAscending Columns("A:A").Find(What:="Trash", After:=Range("A1")).Select Range(Selection, Selection.End(xlDown)).EntireRow.Delete Range("A1").EntireColumn.Delete End Sub "zemarko" wrote in message ... I want to take out 90% of the rows, in order to have a more workable number of rows. How do i eliminate rows at random, i.e. not me selecting? |
All times are GMT +1. The time now is 08:35 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com