【问题标题】:Copy specific columns for particular row (not entire row) into another sheet - Excel Macro将特定行(不是整行)的特定列复制到另一张工作表中 - Excel 宏
【发布时间】:2016-03-16 22:13:53
【问题描述】:

我正在尝试获取一个宏来复制取决于某些条件的行,在本例中为“FX Ccy 选项”,用于使用列 M 的数据表。我已经使用以下代码执行此操作,但我没有'不想复制整行(c.EntireRow.copy)。仅适用于所有包含数据的列 (C:X)。

Sub Button2_Click()

    Dim bottomL As Integer
    bottomL = Sheets("DGM").Range("M" & Rows.Count).End(xlUp).Row: x = 1

    Dim c As Range
    For Each c In Sheets("DGM").Range("M1:M" & bottomL)
        If c.Value = "FX Ccy Options" Then
            c.EntireRow.Copy Worksheets("sheet2").Range("A" & x + 1)
            x = x + 1
        End If
    Next c


End Sub

【问题讨论】:

    标签: vba excel copy rows


    【解决方案1】:
    c.EntireRow.Range("C1:X1").Copy
    

    这里的“C1:X1”是相对到指定的行。

    同样

    someRectangularRange.Range("A1")
    

    someRectangularRange中左上角的单元格

    【讨论】:

    • 我选择了第一名。它工作得很好。谢谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-02
    • 1970-01-01
    • 1970-01-01
    • 2013-11-08
    • 1970-01-01
    相关资源
    最近更新 更多