将特定行(不是整个行)的特定列复制到另一张工作表-Excel Macro [英] Copy specific columns for particular row (not entire row) into another sheet - Excel Macro
本文介绍了将特定行(不是整个行)的特定列复制到另一张工作表-Excel Macro的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图获取一个宏来复制依赖于某些条件的行,在这种情况下为 FX Ccy Options,用于使用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 Sheets( DGM中每个c的范围
).Range( M1:M& bottomL)
如果c.Value = FX Ccy Options然后
c.EntireRow.Copy Worksheets( sheet2)。Range( A& ; x + 1)
x = x + 1
End if
下一个c
End Sub
解决方案
c.EntireRow.Range( C1:X1)。复制
在这里, C1:X1相对于 到指定行。
类似地
someRectangularRange.Range( A1)
是 someRectangularRange
的左上角单元格p>
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
解决方案
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
这篇关于将特定行(不是整个行)的特定列复制到另一张工作表-Excel Macro的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文