Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can i quickly reduce my test data

Excel How To

How can i quickly reduce my test data

by  Chance1234  Posted    (Edited  )
These are two routines i regularly use to reduce my test data .


The first routine hides the middle group of data and the second one randomly removes lines of data, down to a specified size

Code:
Public Sub RemoveMiddleData()
'function to remove the middle data of the graph
Dim intXFirstRow, intXLastRow As Integer
Dim IntCntofRows As Integer
Dim rwIndex As Integer
Dim intCeiling As Integer
Dim strStrip
Dim lrows As Long


intCeiling = 100 'maximum number of rows change to whatever you like

lrows = Sheet1.Rows.Count

For I = 1 To lrows - 1

If Trim(Sheet1.Cells(I + 1, 1).Value) = "" Then Exit For
    
Next I

lrows = I

 If lrows > intCeiling Then
    intXFirstRow = Round(lrows / 3, 0)
    intXLastRow = lrows - (intXFirstRow)
        While intXFirstRow + (intXran - intXLastRow) > intCeiling
            intXFirstRow = intXFirstRow - 1
            intXLastRow = intXLastRow + 1
        Wend
    IntCntofRows = intXFirstRow
    strStrip = intXFirstRow & ":" & intXLastRow
    Sheet1.Range(strStrip).EntireRow.Hidden = True ' hide or delete rows
End If
    
End Sub

Public Sub RandomlyRemoveData()
Dim lrows
Dim intStart
Dim intTarget

intTarget = 60 ' number of rows you want to reduce your data down to

lrows = Sheet1.Rows.Count

For I = 1 To lrows - 1
    If Trim(Sheet1.Cells(I + 1, 1).Value) = "" Then Exit For
Next I

lrows = I

intStart = 1
While lrows > intTarget
    Randomize
    If Int((3 * Rnd) + 1) = 1 Then
        Sheet1.Rows(intStart).Delete
        lrows = lrows - 1
    End If
    intStart = Round(((lrows * Rnd) + 1))
Wend
          
End Sub
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top