Repeat a value or number in a sequence multiple times.

bevonclarke

New Member
Joined
Jul 31, 2019
Messages
3
I have a list say: A,B,C,D,F (IN COLUMN A)
I want the user to select a member of the above list in column B1 and say how many times it must be repeated in column C1. The extracted list can now follow in any other column (a multiple of times say 2)
Example.
User selected A
Repeat 3
List 2 times

The desired output would then be:
A
A
A
B
C
D
E
A
A
A
B
C
D
E

blanks further on.

Please and thank you in advance.
Bevon Clarke
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Try this for results in column "F".
Code:
[COLOR="Navy"]Sub[/COLOR] MG31Jul14
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A1"), Range("A" & Rows.Count).End(xlUp))
[COLOR="Navy"]For[/COLOR] Ac = 1 To 2
[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
    [COLOR="Navy"]If[/COLOR] Dn.Value = [B1] [COLOR="Navy"]Then[/COLOR]
        [COLOR="Navy"]For[/COLOR] n = 1 To [C1]
            c = c + 1
            Cells(c, "F") = Dn.Value
         [COLOR="Navy"]Next[/COLOR] n
    [COLOR="Navy"]Else[/COLOR]
         c = c + 1
         Cells(c, "F") = Dn.Value
     [COLOR="Navy"]End[/COLOR] If
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]Next[/COLOR] Ac
Regards Mick
 
Upvote 0
Without VBA we need helper columns. Maybe something like this


A
B
C
D
E
F
G
H
1
Select​
Repeat​
Repeat List​
Result​
List​
Repeat​
0​
2
A​
3​
2​
A​
A​
3​
3​
3
A​
B​
1​
4​
4
A​
C​
1​
5​
5
B​
D​
1​
6​
6
C​
E​
1​
7​
7
D​
8
E​
9
A​
10
A​
11
A​
12
B​
13
C​
14
D​
15
E​
16

<tbody>
</tbody>


List in F2:F6

Formula in G2 copied down
=IF(A$2=F2,B$2,1)

Formula in H1 copied down
=SUM(G$1:G1)

Formula in D2
=IF(C$2*H$6>=ROWS(D$2:D2),INDEX(F$2:F$6,MATCH(MOD(ROWS(D$2:D2)-1,SUM($G$2:$G$6)),H$1:H$6)),"")

A little complicated, but it works ;)

Hope this helps

M.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,521
Messages
6,114,104
Members
448,548
Latest member
harryls

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