Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Access Array by index

I wanted to accumulate the value in my array.

ARR as Variant

I need to check that does array have value before add to my accumulator.

I tried to access using ARR[i] and ARR(i), but no of them works.

Any information is great appreciated,

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Access Array by index

Sub ABC()

Dim Arr As Variant
ReDim Arr(1 To 10)
For i = 1 To 10
Arr(i) = Int(Rnd() * 100 + 1)
Next
For j = 1 To 10
msg = msg & Arr(j) & IIf(j < 10, ", ", "")
Next
MsgBox msg
End Sub


addresses an array using an index.

--
Regards,
Tom Ogivly

"Souris" wrote in message
...[i]
I wanted to accumulate the value in my array.

ARR as Variant

I need to check that does array have value before add to my accumulator.

I tried to access using ARR and ARR(i), but no of them works.

Any information is great appreciated,



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 107
Default Access Array by index

dim ARR as variant
dim k as integer
dim i as integer
ReDim ARR(1 To k)


For i = 1 To k
If ARR(i).Value Is Empty Then ARR(i).Value = 0
Next i


I wanted to fill 0 if the index of array is null or empty.
It seems that above code didi not work.
Can you please tell me where I was wrong?
Thanks millions,



"Tom Ogilvy" wrote:
[i]
Sub ABC()

Dim Arr As Variant
ReDim Arr(1 To 10)
For i = 1 To 10
Arr(i) = Int(Rnd() * 100 + 1)
Next
For j = 1 To 10
msg = msg & Arr(j) & IIf(j < 10, ", ", "")
Next
MsgBox msg
End Sub


addresses an array using an index.

--
Regards,
Tom Ogivly

"Souris" wrote in message
...
I wanted to accumulate the value in my array.

ARR as Variant

I need to check that does array have value before add to my accumulator.

I tried to access using ARR and ARR(i), but no of them works.

Any information is great appreciated,




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 783
Default Access Array by index

Souris wrote:
dim ARR as variant
dim k as integer
dim i as integer
ReDim ARR(1 To k)


For i = 1 To k
If ARR(i).Value Is Empty Then ARR(i).Value = 0
Next i


I wanted to fill 0 if the index of array is null or empty.
It seems that above code didi not work.
Can you please tell me where I was wrong?
Thanks millions,


If IsEmpty(ARR(i)) Then ARR(i) = 0

Alan Beban
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
Help in finding Value in Index Array George Excel Discussion (Misc queries) 20 October 29th 07 11:48 PM
Index array question LJoe Excel Worksheet Functions 2 August 27th 07 02:14 PM
Vlookup with col index no. array Edward Excel Discussion (Misc queries) 1 September 18th 06 08:23 PM
Using Array Index function in a sub General Excel Programming 2 February 3rd 05 08:28 AM
Index of Minimum value in array Paul Stevens Excel Programming 17 December 8th 03 11:36 AM


All times are GMT +1. The time now is 01:58 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"