+ Reply to Thread
Results 1 to 6 of 6

count # of variants in a list

Hybrid View

  1. #1
    Registered User
    Join Date
    01-29-2007
    Location
    Norway
    Posts
    11

    Thumbs down count # of variants in a list

    hi,

    I am working on a new sheet to list each customer in rows and a number of info in columns. i identify each customer by a 6 didgit numeric number in the first column.

    Sub a()
    Dim myRange As Range, myList As Variant
    Set myRange = Range("a3:q100")
    myList = myRange
    myListRowCount = myRange.Rows.Count 'I want this to be done a bit cooler.

    End Sub

    please take a look at this code. if you F8 it down to the last line you will see in the locals, out from myList = Variant/variant(1 to 98, 1 to 17)

    how can i get the # 98 out in a variable i can use. have tried myList.count but no dice. Please help

    Nolloping
    Last edited by nolloping; 01-29-2007 at 04:09 PM.

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Nolloping,

    You do have the number 98 in a variable, "MyListRowCount". So, what are you trying to do with number?

    Sincerely,
    Leith Ross

  3. #3
    Registered User
    Join Date
    01-29-2007
    Location
    Norway
    Posts
    11
    yes i know in this example i have the number 98, but i want the range to be variable both in rows and colums. i am trying to create a new list based on the variables for eks:

    Sub list()
    Dim nList As Variant, i As Long, pListe() As Variant, _
    myRange As Range

    Set myRange = Worksheets(2).Range("a3:q40")' later i am going to make the range variable based on user input
    nList = myRange.Value
    ReDim pListe(1 To nList) 'i cannot find the last numbered variable
    For i = 1 To UBound(nList)
    pListe(i) = nList(i, 7)
    Next i

    End Sub


    I know i can add another variable by counting the nr. of rows, but that will solve just this example.

    My real question here is: is there a way to count the number of variables in a list like in my example.

    I apologize if I express the question odd. Appreciate any help.
    Last edited by nolloping; 01-30-2007 at 02:08 PM.

  4. #4
    Registered User
    Join Date
    01-29-2007
    Location
    Norway
    Posts
    11
    nList.count ' or
    application.xlListCount ' or

    ?
    anyone?
    Nolloping

  5. #5
    Forum Expert Carim's Avatar
    Join Date
    04-07-2006
    Posts
    4,070
    Hi,

    Are you after ...
    Mylist.List.ListCount
    HTH
    Carim


    Top Excel Links

  6. #6
    Registered User
    Join Date
    01-29-2007
    Location
    Norway
    Posts
    11
    Looks promising. how does that fit that into my last code. i couldn't get it to work.

    Sub list()
    Dim myList As Variant, i As Long, pListe() As Variant, _
    myRange As Range

    Set myRange = Worksheets(2).Range("a3:q40")
    myList = myRange.Value
    per=Mylist.List.ListCount
    ReDim pListe(1 To per)
    For i = 1 To UBound(myList)
    pListe(i) = Liste(i, 7)
    Next i

    End Sub

    it asks me for a objekt. any ideas?
    Last edited by nolloping; 01-31-2007 at 11:40 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1