|
发表于 2010-8-20 18:27
|
显示全部楼层
本楼为最佳答案
Sub test() Dim i As Long Dim x x = InputBox("请输入盘点标签的起始编号", "设定起始编号", 1) For i = 0 To ([A65536].End(xlUp).Row + 1) / 8 - 1 With Sheets(2) Cells(Int(i / 2) * 16 + 3, 4 + 6 * (i Mod 2)).Value = i + x Cells(Int(i / 2) * 16 + 5, 2 + 6 * (i Mod 2)).Value = .Cells(i + x + 1, 2).Value Cells(Int(i / 2) * 16 + 6, 2 + 6 * (i Mod 2)).Value = .Cells(i + x + 1, 3).Value Cells(Int(i / 2) * 16 + 7, 2 + 6 * (i Mod 2)).Value = .Cells(i + x + 1, 4).Value Cells(Int(i / 2) * 16 + 8, 2 + 6 * (i Mod 2)).Value = .Cells(i + x + 1, 6).Value Cells(Int(i / 2) * 16 + 9, 2 + 6 * (i Mod 2)).Value = .Cells(i + x + 1, 5).Value Cells(Int(i / 2) * 16 + 9, 4 + 6 * (i Mod 2)).Value = .Cells(i + x + 1, 7).Value End With Next End Sub |
|