Counting the number of elements within an array that have data

Discussion in 'Microsoft Excel Programming' started by ExcelMonkey, May 17, 2004.

  1. ExcelMonkey

    ExcelMonkey Guest

    I have a 1D VBA array filled with integers. I have gone through th
    array and deleted various element (i.e. array(3) = "",array(7) = "
    etc).

    I now want to count the number of elements within the revised arra
    which contain integers only (or no data at all - whatever is easier).

    How do I do this?

    Thank

    --
     
    ExcelMonkey, May 17, 2004
    #1
    1. Advertisements

  2. ExcelMonkey

    Greg Wilson Guest

    Try:

    MsgBox Application.Count(Array)

    Regards,
    Greg

    >-----Original Message-----
    >I have a 1D VBA array filled with integers. I have gone

    through the
    >array and deleted various element (i.e. array(3)

    = "",array(7) = ""
    >etc).
    >
    >I now want to count the number of elements within the

    revised array
    >which contain integers only (or no data at all - whatever

    is easier).
    >
    >How do I do this?
    >
    >Thanks
    >
    >
    >---
    >Message posted
    >
    >.
    >
     
    Greg Wilson, May 17, 2004
    #2
    1. Advertisements

  3. ExcelMonkey

    Guest Guest

    If you use the code i gave you to transfer the Elements to a New array all you have to do is use UBound(Myarray) to get the upper number and then based on your Option base: 0 = Num -1 OR 1 = Nu

    But if you just want to count then here

    Dim i as single, j as singl
    For i = LBound(YourArray) To UBound(YourArray
    if Not MyArray(i) = "" then j =j+
    Next
    Debug.print "Total number of elements with a value = " &
    Debug.Print "Total number of elements with No Value = " UBound(YourArray) -

    ----- ExcelMonkey > wrote: ----

    I have a 1D VBA array filled with integers. I have gone through th
    array and deleted various element (i.e. array(3) = "",array(7) = "
    etc)

    I now want to count the number of elements within the revised arra
    which contain integers only (or no data at all - whatever is easier)

    How do I do this

    Thank


    --
     
    Guest, May 17, 2004
    #3
  4. ExcelMonkey

    Tom Ogilvy Guest

    Why not count them when you change them?

    --
    Regards,
    Tom Ogilvy

    "ExcelMonkey >" <<> wrote in message
    news:...
    > I have a 1D VBA array filled with integers. I have gone through the
    > array and deleted various element (i.e. array(3) = "",array(7) = ""
    > etc).
    >
    > I now want to count the number of elements within the revised array
    > which contain integers only (or no data at all - whatever is easier).
    >
    > How do I do this?
    >
    > Thanks
    >
    >
    > ---
    > Message posted
    >
     
    Tom Ogilvy, May 17, 2004
    #4
  5. ExcelMonkey

    sheila Guest

    counting recurring part nos. in a list

    i am wondering how i can get excel to count the recurring
    part numbers in a list.
     
    sheila, May 26, 2004
    #5
  6. Re: counting recurring part nos. in a list

    Have you tried using the COUNTIF function?

    Roger
    Shaftesbury (UK)

    "sheila" <> wrote in message
    news:1a2901c4433a$5f6fc0a0$...
    > i am wondering how i can get excel to count the recurring
    > part numbers in a list.
     
    Roger Whitehead, May 26, 2004
    #6
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Guest

    counting column elements

    Guest, Feb 3, 2004, in forum: Microsoft Excel Programming
    Replies:
    2
    Views:
    320
    Tom Ogilvy
    Feb 3, 2004
  2. Guest

    How do I find the number of elements in an Array of Strings?

    Guest, Jun 17, 2005, in forum: Microsoft Excel Programming
    Replies:
    5
    Views:
    9,200
    Ron Rosenfeld
    Jun 17, 2005
  3. Guest

    Number of elements in an array

    Guest, Aug 9, 2005, in forum: Microsoft Excel Programming
    Replies:
    7
    Views:
    529
    Giovanni D via OfficeKB.com
    Aug 12, 2005
  4. Guest

    array within array

    Guest, Jun 21, 2006, in forum: Microsoft Excel Programming
    Replies:
    3
    Views:
    314
    Bob Phillips
    Jun 21, 2006
  5. John

    Resize array based on number of 'used' elements

    John, Jun 21, 2006, in forum: Microsoft Excel Programming
    Replies:
    2
    Views:
    337
  6. Geoff

    counting elements of two arrays

    Geoff, Aug 21, 2007, in forum: Microsoft Excel Programming
    Replies:
    6
    Views:
    378
    Geoff
    Aug 24, 2007
  7. New array with old array elements

    , Aug 22, 2007, in forum: Microsoft Excel Programming
    Replies:
    10
    Views:
    510
    Peter T
    Aug 22, 2007
  8. Guest

    Counting elements of array and range type data

    Guest, Sep 14, 2007, in forum: Microsoft Excel Programming
    Replies:
    13
    Views:
    671
    Alain Vaillancourt
    Sep 16, 2007
Loading...