lookup offset

white6174

Board Regular
Joined
May 6, 2002
Messages
137
Heres what I want to do, I have a filtered list (that is generated with an array formula) in column A. Now in column C I want the same list but with some space's between(the number of space's is in column B, its figuired using a count if based on other criteria)

thanks steve w
Book1.htm
ABCD
4
51010A41010A
61020B3
71030B1
8
9
101020B
11
12
13
141030B
15
16
Sheet1

This message was edited by white6174 on 2002-09-20 14:45
 

Some videos you may like

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Jay Petrulis

MrExcel MVP
Joined
Mar 17, 2002
Messages
2,040
Hi,

The following worked for me. Please test and report your results

<pre>Sub test()
Dim Rng1 As Range, Rng2 As Range
Dim UsedCell As Range, Counter As Long, i As Long
Dim MyArr1, MyArr2, MyArr3, MyArr4

Dim fn As WorksheetFunction
Set fn = Application.WorksheetFunction



With ActiveSheet

Set Rng1 = Intersect(.UsedRange, .Columns(1))
Set Rng2 = Rng1.Offset(0, 1)

For Each UsedCell In Rng1
If Not IsEmpty(UsedCell) Then
Counter = Counter + 1
If Counter = 1 Then
ReDim MyArr1(1 To Counter)
ReDim MyArr2(1 To Counter)
ReDim MyArr3(1 To Counter)
ReDim MyArr4(1 To Counter)
MyArr1(Counter) = UsedCell
MyArr2(Counter) = UsedCell.Offset(0, 1)
MyArr3(Counter) = UsedCell.Row
MyArr4(Counter) = 0
Else
ReDim Preserve MyArr1(1 To Counter)
ReDim Preserve MyArr2(1 To Counter)
ReDim Preserve MyArr3(1 To Counter)
ReDim Preserve MyArr4(1 To Counter)
MyArr1(Counter) = UsedCell
MyArr4(Counter) = fn.Sum(MyArr2) ' note the placement of this

MyArr2(Counter) = UsedCell.Offset(0, 1)
MyArr3(Counter) = UsedCell.Row

End If
End If
Next UsedCell

For i = 1 To Counter
.Cells(MyArr3(i) + MyArr4(i), 3) = MyArr1(i)
Next i

End With

End Sub</pre>
 

white6174

Board Regular
Joined
May 6, 2002
Messages
137
never mind got it to work by opening it in frontpage and got it to work.

thanks alot just what I needed(I new it needed more columns, I thought it needed offset but I haven't used them much)

thanks again

steve w
This message was edited by white6174 on 2002-09-20 17:51
 

Watch MrExcel Video

Forum statistics

Threads
1,127,478
Messages
5,624,996
Members
416,065
Latest member
meiravmeron

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top