If I have a column with many different names of companies, how can I duplicate all values by a certain amount? For example, if I had a column with "Company A, Company B, Company C", how could I make it say "Company A, Company A, Company A, Company B, Company B, Company B, Company C, Company C, Company C"?
如果我有一个包含许多不同公司名称的列,如何将所有值复制一定数量?例如,如果我有一个名为“A公司,B公司,C公司”的专栏,我怎么能说“公司A,公司A,公司A,公司B,公司B,公司B,公司C,公司C” ,公司C“?
1 个解决方案
#1
0
Assuming the original data is in column A and column B is empty, try this small macro:
假设原始数据在A列中而B列为空,请尝试这个小宏:
Sub ThreeTimes()
Dim N As Long, K As Long
N = Cells(Rows.Count, "A").End(xlUp).Row
K = 1
For i = 1 To N
Cells(i, "A").Copy Range(Cells(K, "B"), Cells(K + 2, "B"))
K = Cells(Rows.Count, "B").End(xlUp).Row + 1
Next i
End Sub
#1
0
Assuming the original data is in column A and column B is empty, try this small macro:
假设原始数据在A列中而B列为空,请尝试这个小宏:
Sub ThreeTimes()
Dim N As Long, K As Long
N = Cells(Rows.Count, "A").End(xlUp).Row
K = 1
For i = 1 To N
Cells(i, "A").Copy Range(Cells(K, "B"), Cells(K + 2, "B"))
K = Cells(Rows.Count, "B").End(xlUp).Row + 1
Next i
End Sub