Spreadsheet.SubsetRandomSampling
This property creates a new spreadsheet containing the specified subset of the current spreadsheet using Random Sampling.
Syntax | Parameters | Return Value |
---|---|---|
ReadOnly Property Spreadsheet.SubsetRandomSampling( _ Variables As Variant, _ samplingType As RandomSamplingType, _ PctOrNumberOfCases As Double, _ Optional bWithReplacement As Boolean = False, _ Optional bUseSpreadsheetCaseWeights As Boolean = False) As Spreadsheet |
Which variables to subset. Type: Variant Which sampling method to use. Type: RandomSamplingType Type: Double Type: Boolean Default value: False Type: Boolean Default value: False |
Spreadsheet |
SVB Example
Creating a random sample:
Option Base 1 Option Explicit Sub main Dim spr As Spreadsheet 'assigns the active spreadsheet to the object spr Set spr = ActiveSpreadsheet Dim outputspr As Spreadsheet 'assigns the spreadsheet object outputspr to the spreadsheet generated 'from the SubsetRandomSampling property. 'The first parameter is the number of variables to include in the subset '(Note that "*" = all variables), "1-5" would be used to include variables 1-5 'The second parameter is the sampling type to be used, this is either an approximate 'percentage of the cases or an approximate number of cases. 'The third parameter is the percentage or number of cases you would like to include in the subset 'The fourth parameter determines the use of replacement in the creation of the subset 'The last parameter determines the use of case weights in the creation of the subset Set outputspr = spr.SubsetRandomSampling("*",scRandomSamplingPercentOfCases,50,False,False) 'display the spreadsheet object outputspr outputspr.Visible = True End Sub
Copyright © 2020. Cloud Software Group, Inc. All Rights Reserved.