VBA – Excel组织/复制数据

我正在寻找一种方法来复制和重新排列我使用macros或存在的函数的一些数据。 任何帮助将不胜感激。

先进的谢谢你!

Ĵ

数据是列A中列出的唯一ID号码,如下所示。

唯一的ID号码 - 起点

我正在尝试让每个数字连续重复4次,如下图所示…

在这里输入图像说明

Sub myMacro() ' where data is Dim rowData As Integer rowData = 2 ' where data is duplicated 4 times Dim rowNew As Integer rowNew = 1 ' loop through all entries of column A Do While Range("A" & rowData).Value <> "" Do While rowNew Mod 4 <> 0 ' copy Range("B" & rowNew).Value = Range("A" & rowData).Value rowNew = rowNew + 1 Loop ' last copy Range("B" & rowNew).Value = Range("A" & rowData).Value rowNew = rowNew + 1 ' next row rowData = rowData + 1 Loop End Sub 

B1A栏中的数据input:

 =INDIRECT("A" & ROUNDUP(ROW()/4,0)) 

并抄下来

然后将B列和Paste / Special / Values复制到A