在excel中,如何在连续的列中重复数字x次

在excel中,如何在连续的列中重复数字x次,excel,rows,Excel,Rows,我想做一个列表,比如->1,1,1,2,2,2,3,3,3,3…,但是在excel中的列中。自动执行此操作的公式是什么?请尝试A1: =ROUNDUP(ROW()/4,0) 然后向下复制如果您想使用代码执行此操作,假设您想从第1行开始在A列中执行此操作: x = 1 'the starting row value y = 1 'the starting column value z = 12 'the number of entries you ultimately want to make

我想做一个列表,比如->1,1,1,2,2,2,3,3,3,3…,但是在excel中的列中。自动执行此操作的公式是什么?

请尝试A1

=ROUNDUP(ROW()/4,0)

然后向下复制

如果您想使用代码执行此操作,假设您想从第1行开始在A列中执行此操作:

x = 1 'the starting row value
y = 1 'the starting column value
z = 12 'the number of entries you ultimately want to make
entryEnd = 4 'the number of entries per value
entryStart = 1 'the start of the entries
a = 0 'the starting number of the list of values

Do While x<=z
entryStart = 1 'reset the value of entryStart    
a = a + 1
    Do While entryStart <= entryEnd
    cells(x, y) = a
    x= x + 1
    entryStart = entryStart + 1
    Loop
Loop
x=1'起始行值
y=1'起始列值
z=12'您最终想要创建的条目数
entryEnd=4'每个值的条目数
entryStart=1'条目的开始
a=0'值列表的起始编号
边做边做