Excel 2010 VBA从多个工作表中复制列并附加到活动工作表中

时间:2013-10-14 21:07:45

标签: excel excel-vba vba

如果有人可以帮助我使用VBA,我将非常感激。在同一个WorkBook中循环遍历多个工作表并复制1列,即col B,并粘贴/追加到活动工作表的下一个空白列中。

谢谢, 阿迪尔

2 个答案:

答案 0 :(得分:1)

这里有一些限制,但这应该让你开始。

Sub copyColumn()
    Dim wks As Worksheet
    Set wks = ActiveSheet

    'Source worksheet to copy from
    Dim srcwk As Worksheet
    Set scrwk = ActiveWorkbook.Worksheets(3)

    'Copy range A1:A10 from source to active sheet in next open column
    scrwk.Range("A1:A10").Copy wks.Range("IV1").End(xlToLeft).Offset(0, 1)
End Sub

答案 1 :(得分:0)

这样的东西?

Sub Move_Column()

CurrWS = ActiveSheet.Name
    For each Sheet in ActiveWorkbook.Sheets
        If Sheet.Name <> CurrWS Then
            NextColumn = Sheets(CurrWS).Range("XFD1").End(xlToLeft).Column + 1
            Sheets(CurrWS).Range(Sheets(CurrWS).Cells(1, NextColumn), Sheets(CurrWS).Cells(100, NextColumn)).Value = Sheet.Range(Sheet.Cells(1, 2), Sheet.Cells(100, 2)).Value
        End if
    Next

End Sub