[英]copy cell to another sheet if a different cell in the same row contains text
I am trying to build an interactive worksheet that tracks the status of various funders at a nonprofit.我正在尝试构建一个交互式工作表来跟踪非营利组织中各种资助者的状态。 I need to build a macro that copies the value of column A to a different sheet if the value of column E in the same row = "funded"
如果同一行中 E 列的值 =“已资助”,我需要构建一个宏,将 A 列的值复制到不同的工作表
at present, I can copy the entire row, but I only need the value of column A目前,我可以复制整行,但我只需要A列的值
This is the code that I am using on a similar macro, but for a different sheet.这是我在类似宏上使用的代码,但用于不同的工作表。
Option Compare Text
Sub copyToSheet()
Dim Cell As Range
With Sheets(1)
For Each Cell In .Range("E1:E" & .Cells(.rows.Count, "E").End(xlUp).row)
If Cell.Value = "Upcoming" Then
.rows(Cell.row).Copy Destination:=Sheets(2).rows(Cell.row)
End If
Next Cell
End With
Call deleteEmpties
End Sub
This works well when I need the whole row copied to another sheet, but now I need to copy only the values of certain columns to a new sheet while still testing against the value in column E当我需要将整行复制到另一张工作表时,这很有效,但现在我只需要将某些列的值复制到新工作表,同时仍针对 E 列中的值进行测试
For example:例如:
If Cell.Value = "Upcoming" Then
Cell.entirerow.columns("A").Copy Destination:=Sheets(2).Cells(Cell.row, "A")
End If
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.