Results 1 to 4 of 4

Thread: Looping through columns and arrays

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2004
    Posts
    23

    Looping through columns and arrays

    Hi all, new to vb scripting and trying to get work with an excel document and loop through an column on data and add it to an array

    VB Code:
    1. Dim i
    2. i = 0
    3. Dim bv
    4. Dim arrBan()
    5. Dim CellValue
    6. bv = 3
    7. 'check the length of the column to create an array of good length
    8. Do Until objXL.Cells(bv,15).value = ""
    9. arrBan(i) = objXL.Cells(bv,15).value
    10. i = i + 1
    11. bv = bv + 1
    12. loop

    from this i get a subscript out of range error, the column can be any length so i cant set a value to the array but a dynamic array should work fine right?
    also to see if my thought proccess is right, overall what i am trying to do is compare 2 excel docs to a third, based on the numbers in this column, what i was going to do was get the get the numbers from the 2 sheets and compare them to the third. long proccess i know but i am slowly working on it any advice would be greatly apprecaited

    EDIT: fixed the looping issue the array had to be set to a value, now a better question is there a way to dynamically set a array length based on a number of columns
    Last edited by fizban2; Mar 23rd, 2006 at 03:31 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width