+ Reply to Thread
Results 1 to 2 of 2

Insert row for each different value in a vector

  1. #1
    Alex St-Pierre
    Guest

    Insert row for each different value in a vector

    I have a column B which contains an indicator like AB, AC, AD, AC AA, etc.
    In the firsts column, I want to add line with the different value in cell
    "A1" (for each different indicator). I tried this but doesn't word.

    Dim C As New Collection
    Dim Ndx As Long
    On Error Resume Next
    For Ndx = 1 To 98
    C.Add Range("B3:B100"), Range("B3:B100") 'Range("B3:B100") is my vector
    Next Ndx
    For i = 1 to C.Count
    rows("1:1").insert
    sheets("A1").value = C.value(i)
    next i


    --
    Alex St-Pierre

  2. #2
    Tim Barlow
    Guest

    Re: Insert row for each different value in a vector

    Alex,

    I'm not sure what your trying to do, but try this:


    Dim C As New Collection
    Dim Ndx As Long
    Dim i As Integer

    For Ndx = 3 To 100
    C.Add Cells(Ndx, 2).Value 'Range("B3:B100") is my vector
    Next Ndx

    For i = 1 To C.Count
    Rows("1").Insert
    Range("A1").Value = C(i)
    Next i

    HTH

    Tim


    "Alex St-Pierre" <[email protected]> wrote in message
    news:[email protected]...
    > I have a column B which contains an indicator like AB, AC, AD, AC AA, etc.
    > In the firsts column, I want to add line with the different value in cell
    > "A1" (for each different indicator). I tried this but doesn't word.
    >
    > Dim C As New Collection
    > Dim Ndx As Long
    > On Error Resume Next
    > For Ndx = 1 To 98
    > C.Add Range("B3:B100"), Range("B3:B100") 'Range("B3:B100") is my

    vector
    > Next Ndx
    > For i = 1 to C.Count
    > rows("1:1").insert
    > sheets("A1").value = C.value(i)
    > next i
    >
    >
    > --
    > Alex St-Pierre




+ 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