copy down based on value

donniedorian

Board Regular
Joined
May 27, 2015
Messages
133
Hello,

I need in d2 each cell in b:b for as many times as corresponding in column c:c.

A
B
C
D
1
2
A12
2
A12
3
A13
4
A12
4
A14
6
A13
5
A15
8
A13
6
A16
2
A13
7
A17
1
A13
8
A14
9
A14

<tbody>
</tbody>
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Try this:-
Code:
[COLOR="Navy"]Sub[/COLOR] MG05Jun05
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range("C2", Range("C" & Rows.Count).End(xlUp))
c = 2
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    Cells(c, 4).Resize(Dn.Value) = Dn.Offset(, -1).Value
    c = c + Dn.Value
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Try this:-
Code:
[COLOR=Navy]Sub[/COLOR] MG05Jun05
[COLOR=Navy]Dim[/COLOR] Rng [COLOR=Navy]As[/COLOR] Range, Dn [COLOR=Navy]As[/COLOR] Range, c [COLOR=Navy]As[/COLOR] [COLOR=Navy]Long[/COLOR]
[COLOR=Navy]Set[/COLOR] Rng = Range("C2", Range("C" & Rows.Count).End(xlUp))
c = 2
[COLOR=Navy]For[/COLOR] [COLOR=Navy]Each[/COLOR] Dn [COLOR=Navy]In[/COLOR] Rng
    Cells(c, 4).Resize(Dn.Value) = Dn.Offset(, -1).Value
    c = c + Dn.Value
[COLOR=Navy]Next[/COLOR] Dn
[COLOR=Navy]End[/COLOR] [COLOR=Navy]Sub[/COLOR]
Regards Mick


I try to run the macro but it gives me Error 1004! what else should I do?
 
Upvote 0
Did you try to run the code, on the Data in your thread
If so and it failed, does your data Format show :-

The Text to copy down is in columns "B", The Count for each set of numbers is in column "C" and the results should show in column "D", And the Actual Data starts on row 2

If not please confirm your layout !!!
Perhaps your actual data starts in column "A" ????
 
Upvote 0
Did you try to run the code, on the Data in your thread
If so and it failed, does your data Format show :-

The Text to copy down is in columns "B", The Count for each set of numbers is in column "C" and the results should show in column "D", And the Actual Data starts on row 2

If not please confirm your layout !!!
Perhaps your actual data starts in column "A" ????

Yes the data starts in column A,

Now works like charm, sorry for messing up,
Thanks a lot
 
Upvote 0

Forum statistics

Threads
1,214,924
Messages
6,122,293
Members
449,077
Latest member
Rkmenon

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
Back
Top