#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 8
Default vba outcome

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

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
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


  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,202
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.


This is not true. In VBA, letter casing does not matter. As a matter of
fact, if you Dim your variable in upper case letters and then, in your code,
type it in using lower case letters, VBA will change the case to match that
used in the Dim statement. If you don't Dim the variable (of course you
always should, but if you didn't), VBA will change the letter casing for
**all** uses of that variable to match the letter casing you used the last
time you typed the variable's name.

Rick

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
creating outcome series from formula Maurice Excel Worksheet Functions 9 April 9th 07 06:12 PM
How do I caclculate a ratio where the outcome is X to 1 djerome Excel Worksheet Functions 4 August 30th 06 09:53 PM
format the outcome of a formula tinester Excel Discussion (Misc queries) 3 April 12th 06 07:58 PM
How to calculate a sum as one outcome of an IF statement barb in NC Excel Worksheet Functions 2 March 31st 05 08:01 PM
Stop % showing in outcome of formula Beginner Excel Worksheet Functions 2 January 10th 05 08:09 PM


All times are GMT +1. The time now is 11:53 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"