Thread: vba outcome
View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
bj bj is offline
external usenet poster
 
Posts: 1,397
Default vba outcome

several things

where is length defined?

I would do it as
for i = 2 to length
(by going from 1 to length you have the j going from one to zero the first
iteration, whch it wont do

If A(j) < A )j +1) Then
needs to be
If A(j) < A (j +1) Then

x = a(j +1) = A(j)
needs to be
x=A(j+1)
A(J+1)=A(J)


"harry buggy" wrote:

can anyone tell me if theres any errors in this and what the outcome
would be?

sub test ()

dim I, J As Integer
dim x as single
for i = 1 to length
for j = 1 to (length - i)
If A(j) < A )j +1) Then
x = a(j +1) = A(j)
A(j) = x
end if
next j
next i
end sub