Thread: vba outcome
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Pranav Vaidya Pranav Vaidya is offline
external usenet poster
 
Posts: 180
Default vba outcome

There are few errors in this code

1. I and J are declared as 'I' and 'J' whereas they are used as 'i' and 'j'.
VBA treats variables in small and upper case different.

2. If you are using Option Explicit, this will throw an error as i and j
(small case) are not defined.

3. variable 'length' is not defined


--
Pranav Vaidya
VBA Developer
PN, MH-India
If you think my answer is useful, please rate this post as an ANSWER!!


"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