简体   繁体   English

如果值高于另一个单元格,则复制单元格

[英]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.

相关问题 如果单元格值大于0,excel vba将单元格复制到另一个工作表 - excel vba copy cells to another sheet if cell value is greater than 0 如果单元格包含大于零的值,则将单元格从一张纸复制到另一张纸 - Copy cells from one sheet to another if cell contains a value greater than zero 在多个单元格中找到最大值,然后将该值复制到另一个单元格中 - Find the max value in a number of cells and copy that value into another cell Excel宏,根据另一个单元格值复制和粘贴多个单元格? - Excel macro, to copy and paste a multiple cells based on another cell value? 计算多少个单元格的值高于其下一个单元格的数量(COUNTIF和OFFSET) - Counting how many cells have a higher value than the cell below them (COUNTIF and OFFSET) 如何计算值小于excel中另一个单元格的范围内的单元格? - How to count cells in a range with a value less than another cell in excel? 将单元格值复制到一系列单元格 - Copy cell value to a range of cells 根据单元格值复制单元格 - Copy cells based on cell value 如果范围内只有一个单元格有值,如何将单元格范围内的值复制到另一个单元格? - How to copy the value in a range of cells to another cell if only one cell in the range has a value? 如果区域中只有一个单元格具有值,则将单元格区域中的值复制到另一个单元格 - Copy the value in a range of cells to another cell if only one cell in the range has a value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM