+ Reply to Thread
Results 1 to 3 of 3

How you decimate data using EXCEl (i.e., remove every second or t.

  1. #1
    littlebluesoul
    Guest

    How you decimate data using EXCEl (i.e., remove every second or t.

    I have a data file (over 9000 rows and 10 columns worth of data), and I would
    like to remove every fifth row to reduce the amount of data. How do i
    accomplish this?

  2. #2
    Bernie Deitrick
    Guest

    Re: How you decimate data using EXCEl (i.e., remove every second or t.

    Blue,

    Try the macro below.

    HTH,
    Bernie
    MS Excel MVP

    Sub RemoveEveryFifthRow()
    Dim myRows As Long
    Range("A1").EntireColumn.Insert
    Range("A1").FormulaR1C1 = _
    "=IF(MOD(ROW(),5)=0,""Trash"",""Keep"")"
    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


    "littlebluesoul" <littlebluesoul@discussions.microsoft.com> wrote in message
    news:299AC9B3-3365-4902-86B5-FF960A1140AB@microsoft.com...
    > I have a data file (over 9000 rows and 10 columns worth of data), and I

    would
    > like to remove every fifth row to reduce the amount of data. How do i
    > accomplish this?




  3. #3
    gocush
    Guest

    RE: How you decimate data using EXCEl (i.e., remove every second or t.

    One way:


    Sub DeleteEveryFifthRow()
    Dim lRow As Long
    lRow = Range("A65536").End(xlUp).Row
    Do While lRow > 0
    Cells(lRow, 1).EntireRow.Delete
    lRow = lRow - 5
    Loop
    End Sub


    "littlebluesoul" wrote:

    > I have a data file (over 9000 rows and 10 columns worth of data), and I would
    > like to remove every fifth row to reduce the amount of data. How do i
    > accomplish this?


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1