Copy specific columns for particular row (not enti

2019-09-02 11:33发布

I am trying to get a macro to copy rows dependent on certain criteria, in this case "FX Ccy Options", for a table of data using column M. I have manged to do this with the below code, but I don't want to copy the entire row (c.EntireRow.copy). Just for all the columns with data (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

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-09-02 11:47
c.EntireRow.Range("C1:X1").Copy

Here "C1:X1" is relative to the specificed row.

Similarly

someRectangularRange.Range("A1")

is the top-left cell in someRectangularRange

查看更多
登录 后发表回答