我目前有这样的代码
Sub Rowname()
Const SHEET_NAME As String = "Sheet1"
Const START_ROW As String = "A"
Const ROW_NUM As Long = 1
Const COPY_SIZE As Integer = 2
Dim rng As Range
Set rng = ThisWorkbook.Worksheets(SHEET_NAME).Cells(ROW_NUM, START_ROW)
Do Until IsEmpty(rng)
rng.Offset(1, 0).Resize(COPY_SIZE, 1) = rng.Value2
Set rng = rng.Offset(, COPY_SIZE + 1)
Loop
End Sub
我正在尝试将我的文件名自动循环复制另外2次直到结束。
| A | to something like | A |
|123.jpg| |123.jpg|
| | |123.jpg|
| | |123.jpg|
|456.jpg| |456.jpg|
| | |456.jpg|
| | |456.jpg|
我有大约2000个独特的jpg文件。
答案 0 :(得分:0)
你在这里犯了错误,你的范围按列移动:
Set rng = rng.Offset(, COPY_SIZE + 1)
您需要按行移动它:
Set rng = rng.Offset(COPY_SIZE + 1)