输入数据,总是存在需要在跨越不同的非按顺序行的不同列输出在7个不同的片材的列
Q2_1 Q3_1 Q4_1
13 17 11
4 2 5
3 2 4
2 2 4
6 5 4
行(输出)的顺序为5,10,15,23,28,33,38,43,48,53,61,66,71,79,84,89,94,102,107,112,117 ,122,128,135,140,148,153,158,166,171,179,184,189,194
而列从I5至M5为Q2_1,I10以M10为Q3
我曾尝试2个维权和2个do循环,没有运气。有没有办法使用数组?
我很编程。
Sub CPRelative()
Dim n As Integer
Dim i As Integer
Dim itotal As Integer
Windows("book1.xlsx").Activate
Sheets(3).Select
For n = 2 To 35
ActiveSheet.Range(Cells(4, n), Cells(8, n)).Select
Selection.Copy
Windows("book2.xlsm").Activate
For i = 5 To 194
Select Case i
Case 5, 10, 15, 23, 28, 33, 38, 43, 48, 53, 61, 66, 71, 79, 84, 89, 94, 102, 107, 112, 117, 122, 128, 135, 140, 148, 153, 158, 166, 171, 179, 184, 189, 194
ActiveSheet.Range(Cells(i, 9), Cells(i, 13)).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
End Select
Next n
End Sub
而做,直到做,而
Sub NestedLoop()
Dim n As Integer
Dim i As Integer
Windows("book1.xlsx").Activate
Sheets(3).Select
n = 2
Do Until ActiveSheet.Range(Cells(4, n), Cells(8, n)).Value = ("8,n")
ActiveSheet.Range(Cells(4, n), Cells(8, n)).Select
Selection.Copy
Windows("book2.xlsm").Activate
Sheets(1).Select
'i = 5
Do While ActiveSheet.Range(Cells(i, 9), Cells(i, 13)).Value = ""
Select Case i
Case 5, 10, 15, 23, 28, 33, 38, 43, 48, 53, 61, 66, 71, 79, 84, 89, 94, 102, 107, 112, 117, 122, 128, 135, 140, 148, 153, 158, 166, 171, 179, 184, 189, 194
ActiveSheet.Range(Cells(i, 9), Cells(i, 13)).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
End Select
i = i + 1
Loop
n = n + 1
Loop
End Sub