Aug 30 2021 11:38 AM
Hello,
I don't know why if I type in any cell in an excel sheet that has bootstrap statistics analysis, it resamples again. Please see attached sheet.
Thanks,
Sam
Aug 30 2021 01:16 PM
The range under Bootstrap samples, beginning in B10, contains formulas that use the RAND() function.
RAND() will automatically be recalculated whenever Excel calculates, for example after you edit a cell.
Aug 30 2021 02:37 PM
Aug 30 2021 03:13 PM - edited Aug 30 2021 03:13 PM
In the attached version, the formulas have been replaced with values.
I added a command button that runs a macro to resample the values.
You can view the code in the Visual Basic Editor.
Aug 30 2021 04:03 PM - edited Aug 30 2021 04:04 PM
Hi Hans,
Thank you so much for your help. In the attached sheet that I sent you earlier, I created a tab "Bootstrap (2)". The original samples are in rows numbered(1-3), but each sample row is a separate or independent row. So, I numbered them into rows number 1-3 (red, green, blue). But in reality I have 6000 independent rows in my lab test data Excel sheet. How do you make VBA code so it does the resampling for each row independently for the three rows? I can fix the VBA code once i see how you do it?
Regards,
Sam
Aug 31 2021 12:23 AM
Aug 31 2021 07:10 AM - edited Aug 31 2021 07:18 AM
Hi Hans,
I attached two documents. Let me try again. In my lab tests, i have 30 gas releases in the wind tunnel. For each gas release the the measurement of concentration vs time goes up Excel row 6025. i'd like to generate 500 resamples for each row. Each row represents one time, but we did 30 releases( experiments). Please let me know if you have any questions.
Thanks,
Sam
Aug 31 2021 08:09 AM
You've totally lost me. Your PDF shows 6025 rows but Bootstrap #2 has only 3 rows.
Can you explain in tiny detail, step by step, what you want?
Aug 31 2021 09:41 AM - edited Aug 31 2021 09:41 AM
Hans,
I am attaching the actual Excel Sheet that shows 30 gas releases data. Each release is an experiment on its own. The gas concentrations in the air is a measured with a device and it reads it at different relative times which is shown in A26-A6025. At each relative time you will see the measurements for each relative time. In this experiment 30 samples per relative time is not enough. i need to generate resamples for each row(relative time) for up to 500. I am not sure if you can have the VBA code ask the question how many resamples i need so i can type the number<=500. if i decide to change the numbers of resamples, have it delete the existing and regenerate new resamples based on the new resampling number. this is sheet has the data from lab experiment.
it starts from A26:AF26 and up to row 6025.
Thanks a lot!
Sam
Aug 31 2021 01:02 PM
SolutionTry this:
Sub Resample()
Dim NumSamples As Long
Dim LastRow As Long
NumSamples = Val(InputBox("How many samples do you need (31 - 500)?"))
If NumSamples < 31 Or NumSamples > 500 Then
MsgBox "Invalid input. Must be between 31 and 500!", vbExclamation
Exit Sub
End If
Application.ScreenUpdating = False
LastRow = Range("A" & Rows.Count).End(xlUp).Row
Range("AG26:SH" & LastRow).ClearContents
With Range(Cells(26, 33), Cells(LastRow, NumSamples + 2))
.FormulaR1C1 = "=INDEX(RC3:RC32,RANDBETWEEN(1,30))"
.Value = .Value
End With
Application.ScreenUpdating = True
End Sub
Aug 31 2021 01:02 PM
SolutionTry this:
Sub Resample()
Dim NumSamples As Long
Dim LastRow As Long
NumSamples = Val(InputBox("How many samples do you need (31 - 500)?"))
If NumSamples < 31 Or NumSamples > 500 Then
MsgBox "Invalid input. Must be between 31 and 500!", vbExclamation
Exit Sub
End If
Application.ScreenUpdating = False
LastRow = Range("A" & Rows.Count).End(xlUp).Row
Range("AG26:SH" & LastRow).ClearContents
With Range(Cells(26, 33), Cells(LastRow, NumSamples + 2))
.FormulaR1C1 = "=INDEX(RC3:RC32,RANDBETWEEN(1,30))"
.Value = .Value
End With
Application.ScreenUpdating = True
End Sub