【发布时间】:2015-05-17 18:04:51
【问题描述】:
在实现预期结果方面面临一些困难。 当前结果 = 例如 sheet(input) 中的最后一个值是“Peter” 那么工作表(sheet1)中的整个列将只反映彼得
期望的结果 = 表格(输入)中的最后 2 行值是“大卫”,然后是“彼得”我希望在表格(表格 1)中实现的是范围(B5:B8)反映“大卫”和范围( B9:B12) “彼得”
希望在座的各位能给点建议。在此先感谢:)))
Sub playmacro()
Dim xxx As Long, yyy As Long
ThisWorkbook.Sheets("Input").Range("A2").Activate
Do While ActiveCell.Value <> ""
DoEvents
ActiveCell.Copy
For xxx = 2 To 350 Step 4
yyy = xxx + 3
Worksheets("Sheet1").Activate '"select Sheet1"
With ActiveSheet
'copy the first active cell value from worksheet "input" and paste onto "sheet1" range("B2:B5") basically 1 cell value will occupy 4 rows in "sheet1"
'then jump to the next empty row, return back to worksheet "input" copy the next row value and paste the data into range("B6:B9")
'the loop will keep repeating until sheet "input" activecell value is blank
.Range(Cells(xxx, 2), Cells(yyy, 2)).PasteSpecial xlPasteValues
End With
Next xxx
ThisWorkbook.Sheets("Input").Select
ActiveCell.Offset(1, 0).Activate
Loop
Application.ScreenUpdating = True
End Sub
【问题讨论】: