Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Vba in excel code help Traveling Salesman Problem 3 Distance City1City2 City 3 C

ID: 3735009 • Letter: V

Question

Vba in excel code help Traveling Salesman Problem 3 Distance City1City2 City 3 City 4 City 5 80 76 City 1 5 City 2 6 City 3 7 City 4 8 City 5 0 62 86 80 76 62 0 82 86 82 85 70 85 70 84 10 From 11 To 12 Distance 13 Tot Distance 84 80 82 70 62 298

Explanation / Answer

Here is a UDF which will allow you to specify the sample size and lower and upper bounds.This is intended to be a worksheet array. Preselect a range equal to the the desired number of samples, enter the formula, and confirm with Ctrl-Shift-Enter. Source code Function _ SampleNoReplace _ ( _ SampleSize As Long, _ LowerBound As Long, _ UpperBound As Long, _ Optional IsStatic As Boolean = False _ ) Dim PopulationCollection As Collection Dim Cell As Range Dim SampleArray, _ temp As Long, _ i As Long, _ j As Long If Not (IsStatic) Then Excel.Application.Volatile True Randomize If UpperBound (UpperBound - LowerBound + 1) Or SampleSize 1 And .Columns.Count > 1 Then Dim Rws As Long, _ Cols As Long, _ k As Long, _ SampleArrayResize() Rws = .Rows.Count Cols = .Columns.Count ReDim SampleArrayResize(1 To Rws, 1 To Cols) For i = 1 To Rws For j = 1 To Cols k = k + 1 SampleArrayResize(i, j) = SampleArray(k) Next j Next i SampleNoReplace = SampleArrayResize ElseIf .Rows.Count > 1 Then SampleNoReplace = Excel.Application.Transpose(SampleArray) Else SampleNoReplace = SampleArray End If End With End If End With End Function