我在簡化將數據複製並粘貼到各種表單中的宏時遇到了困難。VBA - 簡化的複製和粘貼宏
'Put the date and time across the top
Dim rngDT As Range
Set rngDT = Worksheets("Data").Range("A2:B2")
Worksheets("Data").Range(rngDT, rngDT.End(xlDown)).Copy
Worksheets("Reporting").Range("C5").Offset((x - 1) * 12, 0).PasteSpecial _
Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
'Copy and transpose the names from the names page
Worksheets("Point Names").Range("B1:B3").Offset(x, 0).Copy _
(Worksheets("Reporting").Range("B7").Offset((x - 1) * 12, 0))
'Copy and transpose the data
Dim dataRng As Range
Set dataRng = Worksheets("Data").Range("C1:E1").Offset(1, 3 * x - 3) '.Range("A1:C1")
Worksheets("Data").Range(dataRng, dataRng.End(xlDown)).Copy
Worksheets("Reporting").Range("C7").Offset((x - 1) * 12, 0).PasteSpecial _
Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:=False, Transpose:=True
'Sheets("Data").Select
'Range("A1").Select
'ActiveCell.Offset(1, x + 1).Range("A1:C1").Select
'Range(Selection, Selection.End(xlDown)).Select
'Selection.Copy
'Sheets("Reporting").Select
'Range("C7").Offset((x - 1) * 12, 0).Select
'Selection.PasteSpecial Paste:=xlPasteAll, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=True
同樣爲了參考,在本例中環路For x = 1 To NumPoints
其中NumPoints = 33
。謝謝你在前進,任何幫助將不勝感激
什麼是「選擇」? – sourceCode
@sourceCode顯然是他選擇之前一行的範圍? –