Doubble loop to copy and paste

  • Thread starter Thread starter Snoopy
  • Start date Start date
S

Snoopy

Hey guys :)

My table goes like this:
A B C D E F ........
_________________________
1 | 1 Title 1
2 | 1 Subtitle a
3 | 1 Subtitle b
4 | 1 Subtitle c
5 | 1 Title 2
6 | 1 Subtitle d
7 | 1 Subtitle e
8 | 1 Title 2
9 | 1 Subtitle f

.... and so on.

What I want the macro to do is this; for each value "1" in column A,
copy the "Title n" in column E into column D in the following cells
(until next "1" in column A) where value "1" appears in column B. Get
it?

The result should be something like this:
A B C D E F ........
__________________________
1 | 1 Title 1
2 | 1 Title 1 Subtitle a
3 | 1 Title 1 Subtitle b
4 | 1 Title 1 Subtitle c
5 | 1 Title 2
6 | 1 Title 2 Subtitle d
7 | 1 Title 2 Subtitle e
8 | 1 Title 3
9 | 1 Title 3 Subtitle f
.... and so on.

Is there any kindly and helpful "EXCEL-alien" out in VBA-space that
will give me some help on this?

Regards
Snoopy
 
Perhaps try also a non array formulas approach ?

Put in F1: =IF(A1="","",COUNT($A$1:A1))
Copy F1 down to last row of data in col A

Put in D1:
=IF(INDEX(E:E,MATCH(COUNT($F$1:F1),F:F,0))=E1,"",
INDEX(E:E,MATCH(COUNT($F$1:F1),F:F,0)))
Copy D1 down to last row of data in col D

Col D seems to return what's required ..
 

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

Back
Top