[英]Copy cells if value is higher than another cell
I have a cell ( U4 , for example) where I insert a value. 我有一个单元格(例如U4 ),在其中插入值。 I'll call it A, for example.
例如,我将其称为A。
I want to copy all the values in Column K higher than A (starting in row 4), and place them in Column N (starting in row 4 also). 我想复制K列中所有高于A的值(从第4行开始),并将它们放在N列(也从第4行开始)中。 Besides that, i want to copy the correspondent values in Column L and place them in column O.
除此之外,我想将对应的值复制到L列中并将它们放在O列中。
Right now I have this, just for Column K: 现在,我有这个,仅针对K列:
A = Range("U4").Value
Cotacopy = 4
With Range("K4")
If .Cells(1, 1).Value > A Then
Range(.Cells(1, 1), .End(xlDown)).Copy Destination:=Sheets("Cálculo").Range("N" & Cotacopy)
x = x + 1
Else
End If
End With
I don't know if this is entirely correct, i'm adapting another process where i copy all the cells in one column that have value. 我不知道这是否完全正确,我正在适应另一种过程,即我将所有具有值的单元格复制到一个列中。
How about the following For loop : 下面的For循环如何:
Sub CopyHigherValue()
Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
y = 4
For x = 4 To lastrow
If Cells(x, 1).Value < Cells(x, 11).Value Then
Cells(y, 14).Value = Cells(x, 11).Value
Cells(y, 15).Value = Cells(x, 12).Value
y = y + 1
End If
Next x
End Sub
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.