Insert row for each different value in a vector

A

Alex St-Pierre

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
 
T

Tim Barlow

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
 

Ask a Question

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. After that, you can post your question and our members will help you out.

Ask a Question

Top