Question: I want to create a vba code that bubble sorts sorts a 2d excell spreadsheet consisting of a 20 row by 10 column array. I

I want to create a vba code that bubble sorts sorts a 2d excell spreadsheet consisting of a 20 row by 10 column array. I have attached a image of my code for a 1D array bubble sort. I just have trouble applying this to 2 dimensionsI want to create a vba code that bubble sorts sorts a

2d excell spreadsheet consisting of a 20 row by 10 column array.

Vbubblesort Sub bubblesort() Dim temp As Double Dim i As Integer Dim k As Integer Dim rowsnumb As Integer For k 1 To rowsnumb- 1 Do Until i = rowsnumb-k + 1 If ActiveSheet.Cells (i, 1) .Value > ActiveSheet.Cells (i +1, 1).Value Then temp ActiveSheet.Cells (i, 1). Value Activesheet.Cells (i, 1).Value ActiveSheet.Cells(i ActiveSheet.Cells (i + 1, 1) .Value temp 1, 1).Value End If Loop Next End Sub Vbubblesort Sub bubblesort() Dim temp As Double Dim i As Integer Dim k As Integer Dim rowsnumb As Integer For k 1 To rowsnumb- 1 Do Until i = rowsnumb-k + 1 If ActiveSheet.Cells (i, 1) .Value > ActiveSheet.Cells (i +1, 1).Value Then temp ActiveSheet.Cells (i, 1). Value Activesheet.Cells (i, 1).Value ActiveSheet.Cells(i ActiveSheet.Cells (i + 1, 1) .Value temp 1, 1).Value End If Loop Next End Sub

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!