I'm attempting to use Excel to execute what is ostensibly a straightforward bubble sort algorithm. I've attempted to run bubble sort several times, but each time I receive the message "Compile error sub or function is not declared." I'm making use of the code my professor provided. Thank you.
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 vba syntax checker. But quite frankly, I have no experience with vb and do not know where to start.