Home |
Search |
Today's Posts |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
SG,
You have to increment the Array. I started from scratch and wrote something I think is close to what you want? See if this is any help... '------------------------------------------------------- Sub AnotherTest() Dim i As Long Dim N As Long Dim X As Long Dim SearchRange As Excel.Range Dim varr() As Double Set SearchRange = Range(Cells(10, 1), Cells(Rows.Count, 1).End(xlUp)) N = SearchRange.Count ReDim varr(1 To N) For i = N To 1 Step -1 If SearchRange(i).Value = "Now Cough" Then X = X + 1 varr(X) = SearchRange(i).Offset(0, 1).Value End If Next 'i ReDim Preserve varr(1 To X) 'Just an example - as could run out of columns Range(Cells(5, 4), Cells(5, 3 + X)).Value = varr() Set SearchRange = Nothing End Sub '------------------------------------------------------------ Regards, Jim Cone San Francisco, USA "S G Booth" wrote in message ... I'm searching up a column looking for a particular value. When found, I need to add a range offset from that cell to an array. I find that the following code is overwriting varr(1) each time....so the array never builds correctly i = i + 1 If IsEmpty(varr(1)) Then Set varr(1) = .Range("B" & StartRw) Else ReDim Preserve varr(1 To UBound(varr) + 1) Set varr(UBound(varr)) = .Range("B" & StartRw) End If Why is the array not building correctly, please? Regards |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Array Question | Excel Discussion (Misc queries) | |||
array question | Excel Worksheet Functions | |||
Array Question | Excel Discussion (Misc queries) | |||
Increment array for debits and credits | Excel Programming | |||
Increment array range | Excel Programming |