I'm trying to run what is supposed to be a simple bubblesort algo in excel. Every time I've tried to run bubble sort, I get an error stating, "Compile error sub or function is not defined." I am using the code my professor gave me. Please help.
Sub BubbleSort()
' Sorts an array using bubble sort algorithm
For i = 1 To 20
For j = 1 To 20 - i
If Cells(j, 1) > Cells(j + 1, 1) Then
Temp = Cells(j, 1)
Sleep 10
Cells(j, 1) = Cells(j + 1, 1)
Cells(j + 1, 1) = Temp
Application.Wait (Now + TimeValue("0:00:001"))
End If
Next
Next
End Sub
I have tried using a vb sytax checker. But quite frankly, I have no experience with vb and do not know where to start.