Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 dimensions
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 SubStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started