Repeating a list of cells in excel X number of times











up vote
0
down vote

favorite












I have a list of names in excel,



For example



Lizzy
William
Kate
Charles


I would like to use some VBA code (or other method to repeat this 12 times).



I will be doing this over and over again and sometimes my list of names may include less or more.



Has anyone got any direction for me as I am really stuck.



The output I would like in this specific case is,



Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles


What I have tried:



I have found a method using formulas, see, https://www.excel-bytes.com/how-to-repeat-a-range-of-items-multiple-times-in-excel/



However the problem with this is the indexing the initial list as my list will change.
Link to question put on hold: Copy and paste a list of names in excel 12 times




This question was originally asked by another user and put on hold so
I couldn't answer. I have a solution so I have reasked the question
and I will provide an answer and tag the original asker.











share|improve this question







New contributor




Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • @Zarina Akhtar please see answer
    – Tony Chivers
    19 hours ago















up vote
0
down vote

favorite












I have a list of names in excel,



For example



Lizzy
William
Kate
Charles


I would like to use some VBA code (or other method to repeat this 12 times).



I will be doing this over and over again and sometimes my list of names may include less or more.



Has anyone got any direction for me as I am really stuck.



The output I would like in this specific case is,



Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles


What I have tried:



I have found a method using formulas, see, https://www.excel-bytes.com/how-to-repeat-a-range-of-items-multiple-times-in-excel/



However the problem with this is the indexing the initial list as my list will change.
Link to question put on hold: Copy and paste a list of names in excel 12 times




This question was originally asked by another user and put on hold so
I couldn't answer. I have a solution so I have reasked the question
and I will provide an answer and tag the original asker.











share|improve this question







New contributor




Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • @Zarina Akhtar please see answer
    – Tony Chivers
    19 hours ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I have a list of names in excel,



For example



Lizzy
William
Kate
Charles


I would like to use some VBA code (or other method to repeat this 12 times).



I will be doing this over and over again and sometimes my list of names may include less or more.



Has anyone got any direction for me as I am really stuck.



The output I would like in this specific case is,



Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles


What I have tried:



I have found a method using formulas, see, https://www.excel-bytes.com/how-to-repeat-a-range-of-items-multiple-times-in-excel/



However the problem with this is the indexing the initial list as my list will change.
Link to question put on hold: Copy and paste a list of names in excel 12 times




This question was originally asked by another user and put on hold so
I couldn't answer. I have a solution so I have reasked the question
and I will provide an answer and tag the original asker.











share|improve this question







New contributor




Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I have a list of names in excel,



For example



Lizzy
William
Kate
Charles


I would like to use some VBA code (or other method to repeat this 12 times).



I will be doing this over and over again and sometimes my list of names may include less or more.



Has anyone got any direction for me as I am really stuck.



The output I would like in this specific case is,



Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles
Lizzy
William
Kate
Charles


What I have tried:



I have found a method using formulas, see, https://www.excel-bytes.com/how-to-repeat-a-range-of-items-multiple-times-in-excel/



However the problem with this is the indexing the initial list as my list will change.
Link to question put on hold: Copy and paste a list of names in excel 12 times




This question was originally asked by another user and put on hold so
I couldn't answer. I have a solution so I have reasked the question
and I will provide an answer and tag the original asker.








microsoft-excel vba






share|improve this question







New contributor




Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question







New contributor




Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question






New contributor




Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 19 hours ago









Tony Chivers

164




164




New contributor




Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • @Zarina Akhtar please see answer
    – Tony Chivers
    19 hours ago


















  • @Zarina Akhtar please see answer
    – Tony Chivers
    19 hours ago
















@Zarina Akhtar please see answer
– Tony Chivers
19 hours ago




@Zarina Akhtar please see answer
– Tony Chivers
19 hours ago










1 Answer
1






active

oldest

votes

















up vote
1
down vote













For any list of names in the first column of an excel spreadsheet, this VBA code will repeat based on the entry in cell C2, therefore, if you want the list repeated 10 times and there are 10 names in the original list, insert a 110 in the original list.



    Option Explicit

Sub LRow()

Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sheet1") '<=== Edit Sheet Name
Dim LRow As Long

LRow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row

ws.Range("A1:A" & LRow).Select

End Sub


Is the first but of code that you need and it essentially highlights anything in the A column.



The second part of the code drags down the list so that it is repeated.



Add them both in and run the second as a macro.



I hope this helps.



    Sub Master()
'
' Master Macro
'

'
LRow
Selection.AutoFill Destination:=Range("A1:A" & Range("C2").Value), Type:=xlFillDefault
Range("A1:A" & Range("C2").Value).Select
Range("B1").Select
End Sub





share|improve this answer










New contributor




Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 1




    However stupid it may sound, I have to ask: Is there anything wrong with typing in the list, then dragging down (lower right corner repetition mark) up to 12 times? You may end up short or long, but no code is needed, and it's fast.
    – DroidW
    17 hours ago








  • 1




    Yes, I see your point, but I think the original asker want to have a foolproof way that could be used in other automation processes. "I will be doing this over and over again and sometimes my list of names may include less or more."
    – Tony Chivers
    17 hours ago






  • 1




    Crystal clear, thank you.
    – DroidW
    16 hours ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






Tony Chivers is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1374954%2frepeating-a-list-of-cells-in-excel-x-number-of-times%23new-answer', 'question_page');
}
);

Post as a guest
































1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













For any list of names in the first column of an excel spreadsheet, this VBA code will repeat based on the entry in cell C2, therefore, if you want the list repeated 10 times and there are 10 names in the original list, insert a 110 in the original list.



    Option Explicit

Sub LRow()

Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sheet1") '<=== Edit Sheet Name
Dim LRow As Long

LRow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row

ws.Range("A1:A" & LRow).Select

End Sub


Is the first but of code that you need and it essentially highlights anything in the A column.



The second part of the code drags down the list so that it is repeated.



Add them both in and run the second as a macro.



I hope this helps.



    Sub Master()
'
' Master Macro
'

'
LRow
Selection.AutoFill Destination:=Range("A1:A" & Range("C2").Value), Type:=xlFillDefault
Range("A1:A" & Range("C2").Value).Select
Range("B1").Select
End Sub





share|improve this answer










New contributor




Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 1




    However stupid it may sound, I have to ask: Is there anything wrong with typing in the list, then dragging down (lower right corner repetition mark) up to 12 times? You may end up short or long, but no code is needed, and it's fast.
    – DroidW
    17 hours ago








  • 1




    Yes, I see your point, but I think the original asker want to have a foolproof way that could be used in other automation processes. "I will be doing this over and over again and sometimes my list of names may include less or more."
    – Tony Chivers
    17 hours ago






  • 1




    Crystal clear, thank you.
    – DroidW
    16 hours ago















up vote
1
down vote













For any list of names in the first column of an excel spreadsheet, this VBA code will repeat based on the entry in cell C2, therefore, if you want the list repeated 10 times and there are 10 names in the original list, insert a 110 in the original list.



    Option Explicit

Sub LRow()

Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sheet1") '<=== Edit Sheet Name
Dim LRow As Long

LRow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row

ws.Range("A1:A" & LRow).Select

End Sub


Is the first but of code that you need and it essentially highlights anything in the A column.



The second part of the code drags down the list so that it is repeated.



Add them both in and run the second as a macro.



I hope this helps.



    Sub Master()
'
' Master Macro
'

'
LRow
Selection.AutoFill Destination:=Range("A1:A" & Range("C2").Value), Type:=xlFillDefault
Range("A1:A" & Range("C2").Value).Select
Range("B1").Select
End Sub





share|improve this answer










New contributor




Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.














  • 1




    However stupid it may sound, I have to ask: Is there anything wrong with typing in the list, then dragging down (lower right corner repetition mark) up to 12 times? You may end up short or long, but no code is needed, and it's fast.
    – DroidW
    17 hours ago








  • 1




    Yes, I see your point, but I think the original asker want to have a foolproof way that could be used in other automation processes. "I will be doing this over and over again and sometimes my list of names may include less or more."
    – Tony Chivers
    17 hours ago






  • 1




    Crystal clear, thank you.
    – DroidW
    16 hours ago













up vote
1
down vote










up vote
1
down vote









For any list of names in the first column of an excel spreadsheet, this VBA code will repeat based on the entry in cell C2, therefore, if you want the list repeated 10 times and there are 10 names in the original list, insert a 110 in the original list.



    Option Explicit

Sub LRow()

Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sheet1") '<=== Edit Sheet Name
Dim LRow As Long

LRow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row

ws.Range("A1:A" & LRow).Select

End Sub


Is the first but of code that you need and it essentially highlights anything in the A column.



The second part of the code drags down the list so that it is repeated.



Add them both in and run the second as a macro.



I hope this helps.



    Sub Master()
'
' Master Macro
'

'
LRow
Selection.AutoFill Destination:=Range("A1:A" & Range("C2").Value), Type:=xlFillDefault
Range("A1:A" & Range("C2").Value).Select
Range("B1").Select
End Sub





share|improve this answer










New contributor




Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









For any list of names in the first column of an excel spreadsheet, this VBA code will repeat based on the entry in cell C2, therefore, if you want the list repeated 10 times and there are 10 names in the original list, insert a 110 in the original list.



    Option Explicit

Sub LRow()

Dim ws As Worksheet: Set ws = ThisWorkbook.Sheets("Sheet1") '<=== Edit Sheet Name
Dim LRow As Long

LRow = ws.Range("A" & ws.Rows.Count).End(xlUp).Row

ws.Range("A1:A" & LRow).Select

End Sub


Is the first but of code that you need and it essentially highlights anything in the A column.



The second part of the code drags down the list so that it is repeated.



Add them both in and run the second as a macro.



I hope this helps.



    Sub Master()
'
' Master Macro
'

'
LRow
Selection.AutoFill Destination:=Range("A1:A" & Range("C2").Value), Type:=xlFillDefault
Range("A1:A" & Range("C2").Value).Select
Range("B1").Select
End Sub






share|improve this answer










New contributor




Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer








edited 17 hours ago





















New contributor




Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered 19 hours ago









Tony Chivers

164




164




New contributor




Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Tony Chivers is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 1




    However stupid it may sound, I have to ask: Is there anything wrong with typing in the list, then dragging down (lower right corner repetition mark) up to 12 times? You may end up short or long, but no code is needed, and it's fast.
    – DroidW
    17 hours ago








  • 1




    Yes, I see your point, but I think the original asker want to have a foolproof way that could be used in other automation processes. "I will be doing this over and over again and sometimes my list of names may include less or more."
    – Tony Chivers
    17 hours ago






  • 1




    Crystal clear, thank you.
    – DroidW
    16 hours ago














  • 1




    However stupid it may sound, I have to ask: Is there anything wrong with typing in the list, then dragging down (lower right corner repetition mark) up to 12 times? You may end up short or long, but no code is needed, and it's fast.
    – DroidW
    17 hours ago








  • 1




    Yes, I see your point, but I think the original asker want to have a foolproof way that could be used in other automation processes. "I will be doing this over and over again and sometimes my list of names may include less or more."
    – Tony Chivers
    17 hours ago






  • 1




    Crystal clear, thank you.
    – DroidW
    16 hours ago








1




1




However stupid it may sound, I have to ask: Is there anything wrong with typing in the list, then dragging down (lower right corner repetition mark) up to 12 times? You may end up short or long, but no code is needed, and it's fast.
– DroidW
17 hours ago






However stupid it may sound, I have to ask: Is there anything wrong with typing in the list, then dragging down (lower right corner repetition mark) up to 12 times? You may end up short or long, but no code is needed, and it's fast.
– DroidW
17 hours ago






1




1




Yes, I see your point, but I think the original asker want to have a foolproof way that could be used in other automation processes. "I will be doing this over and over again and sometimes my list of names may include less or more."
– Tony Chivers
17 hours ago




Yes, I see your point, but I think the original asker want to have a foolproof way that could be used in other automation processes. "I will be doing this over and over again and sometimes my list of names may include less or more."
– Tony Chivers
17 hours ago




1




1




Crystal clear, thank you.
– DroidW
16 hours ago




Crystal clear, thank you.
– DroidW
16 hours ago










Tony Chivers is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















Tony Chivers is a new contributor. Be nice, and check out our Code of Conduct.













Tony Chivers is a new contributor. Be nice, and check out our Code of Conduct.












Tony Chivers is a new contributor. Be nice, and check out our Code of Conduct.















 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1374954%2frepeating-a-list-of-cells-in-excel-x-number-of-times%23new-answer', 'question_page');
}
);

Post as a guest




















































































Popular posts from this blog

Сан-Квентин

Алькесар

Josef Freinademetz