0
什麼是增加每個範圍的好方法,例如我需要x將範圍B11:複製到G20並將其粘貼到C10以進行第二個循環。每個變量具有不同的增量。因爲我是可怕的用Visual BasicVBA什麼是循環中增量的最佳方式
進出口使用Excel 2010中
任何幫助表示讚賞。
Dim i As Range, j As Range, k As Range
Dim x As Range, y As Range
Dim Num As Integer
Num = 94
Set x = Sheets("Sum Data").Range("B1:G10")
Set j = Sheets("PNA Physical Needs Summary Data").Range("C4")
Set i = Sheets("PNA Physical Needs Summary Data").Range("B4:B9")
Set k = Sheets("Sum Data").Range("A1")
Set p = Sheets("PNA Physical Needs Summary Data").Range("P3:P8")
Set e = Sheets("PNA Physical Needs Summary Data").Range("A4:A9")
Do
Sheets("Sum Data").Select
x.Copy
Sheets("PNA Physical Needs Summary Data").Select
j.Select
Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
p.Select
Selection.Copy
i.Select
ActiveSheet.Paste
Sheets("Sum Data").Select
k.Select
Application.CutCopyMode = False
Selection.Copy
Sheets("PNA Physical Needs Summary Data").Select
e.Activate
ActiveSheet.Paste
Num = Num - 1
Loop Until Num = 0
好吧,我改變了複製和粘貼,我有嘗試了循環中的偏移量,但它在特定頁面上停留並且不會增加。做 x.Copy 表( 「PNA生理需要摘要數據」)選擇 j.Select Selection.PasteSpecial貼:= xlPasteAll,操作:= xlNone,SkipBlanks:= _ 假,移調:=真 p .Copy我 k.CopyË 貨號=貨號 - 1 X = x.Offset(10,0) J = j.Offset(5,0) I = i.Offset(5,0) k = k.Offset(10,0) e = e.Offset(5,0) – user1139384 2012-01-09 20:01:59
「卡住」是什麼意思?我注意到當你移動範圍時你沒有使用「Set」:需要。 – 2012-01-09 20:46:34