我有一张表格,我会做一些微积分,我想将完整的“结果”复制到另一张表格,称为“结果”。
问题是我在A和B列,C和D,E和F中有值(成对,它们是连接的)。我想复制它们(成对)并将它们粘贴在“结果”表中,例如在列D和E中,但都是“在线”。
首先是A和B,然后是上面两行,从C和D开始,然后(上面两行)我从E和F粘贴值。
因此,有什么方法可以调整打印区域,具体取决于结果的大小?
我有这个:
我想要这个
答案 0 :(得分:0)
这应该可以完成工作,虽然你的解释和你的数字不匹配:
Sub test()
'Select sheet where data source is placed
Sheets("Data Source").Activate
'Declare variables for ranges
Dim Rng1, Rng2, Rng3 As Range
Set Rng1 = Range(Range("A3"), Range("B3").End(xlDown)) 'Define range in columns A:B
Set Rng2 = Range(Range("C3"), Range("D3").End(xlDown)) 'Define range in columns C:D
Set Rng3 = Range(Range("E3"), Range("F3").End(xlDown)) 'Define range in columns E:F
'Declare variables quantity of rows in each range
Dim r, r1, r2, r3 As Long
r = 2 'first blank rows
r1 = Rng1.Rows.Count
r2 = Rng2.Rows.Count
r3 = Rng3.Rows.Count
'Go to sheet Results
Sheets("Results").Activate
'Copy data into sheet Results
Range(Cells(r + 1, 1), Cells(r, 2).Offset(r1, 0)).Value = Rng1.Value
r = r + r1 + 2 '(2) represents the number of rows spacing the two tables
Range(Cells(r + 1, 1), Cells(r, 2).Offset(r2, 0)).Value = Rng2.Value
r = r + r2 + 2 '(2) represents the number of rows spacing the two tables
Range(Cells(r + 1, 1), Cells(r, 2).Offset(r3, 0)).Value = Rng3.Value
End Sub