Results 1 to 20 of 66

Thread: Help Required : Random Sampling of Data

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    VBAX Mentor
    Joined
    Nov 2020
    Location
    Cochin, Kerala
    Posts
    314
    Location
    Hi snb,

    I have replaced my codes with the one you suggested for simple random sampling. And now I understand how simple and short is the code you suggested.

    Public LR      As Long                            'Last Row
    Public LC      As Long                            ' Last Column
    Public SS      As Long                            'Sample Size
    
    SS = Me.txtRandomCount.Text    
        With ActiveSheet
            .Cells(1, LC + 1) = "Sample"
            .Range(Cells(2, LC + 1), Cells(LR, LC + 1)).Name = "Sample"
            [Sample] = "=rand()"
            [Sample] = [index(rank(Sample,Sample),)]
            Set myrange = [Sample]
            For Each mycell In myrange
                If mycell.Value <= SS Then
                    mycell.Value = "Yes"
                Else
                    mycell.Value = Empty
                End If
            Next mycell
        End With
    For the stratified sampling - Could you please guide me, how to apply rand() and rank based on each unique values in the filed selected both for equal and proportionate methods?
    Attached Files Attached Files

Posting Permissions

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