简体   繁体   English

如果同一行中的不同单元格包含文本,则将单元格复制到另一张工作表

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

相关问题 如果该单元格包含特定文本,则将单元格从一张工作表复制到另一张工作表 - Copy a cell from one sheet to another sheet if that cell contains a particular text Excel:如果列中的单元格= X的文本值,则在另一个工作表上显示文本(在同一行,但不同的列) - Excel: If Cell in Column = text value of X, then display text (in the same row, but different column) on another sheet 根据单元格中的值将行复制到另一张工作表 - Copy row to another sheet based on value in a cell 如果工作表上的单元格值与另一张表上的单元格值相同,则删除该行 - Delete the row if the cell value on sheet is the same then the cell value on another sheet 如果单元格包含特定文本,则复制整行 - if cell contains specific text, copy whole row 查找文本并将相邻的单元格复制到其他工作表 - find text and copy adjacent cell to different sheet 双击复制单元格并自动粘贴到另一张纸上的不同单元格 - Copy A Cell On Double Click And Paste to A Different Cell on Another Sheet Automatically 使用For循环根据VBA中单元格中的文本将整行从工作表复制到另一个工作表 - Copy an entire row from a sheet to another sheet on basis of text in a cell in VBA using For loop 如果单元格包含特定文本,请将整行和接下来的两行复制到excel 2013中的下一张工作表 - If a cell contains specific text, copy the whole row & the next two rows to next sheet in excel 2013 复制单元格,如果它包含文本 - copy cell if it contains text
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM