简体   繁体   English

在所有工作表中查找特定文本,如果匹配,则将相同行但不同列值的值写入主工作表

[英]Lookup in all the sheets for specific text and if match then write value of same row but different column value to master sheet

  • check over all sheets 检查所有工作表
  • If specific text (eg, yes) is found in the fifth row of a sheet, get data from that row (but different column) and write data to a master sheet How can I do that? 如果在工作表的第五行中找到特定的文本(例如,是),请从该行(但不同的列)中获取数据,然后将数据写入主表中。我该怎么做?

I found below code relatively useful for me but, not 100% matching with my requirement. 我发现以下代码对我而言相对有用,但并非100%符合我的要求。 please help me on this. 请帮助我。

Problem in this code is:- i have specific text(yes) in specific range(e6:e16). 这段代码中的问题是:-我在特定范围(e6:e16)中有特定的文本(是)。 What I want is to check for only yes word. 我想要的只是检查是的单词。 If found then write value of column A & row, in which yes word found, into master sheet and check it till last sheet. 如果找到,则将在其中找到了单词的A列和行的值写入主表,并检查直到最后一张。

Sub SeachSheets()

    Dim FirstAddress As String, WhatFor As String
    Dim Cell As Range, Sheet As Worksheet

    WhatFor = InputBox("What are you looking for?", "Search Criteria")
    If WhatFor = Empty Then Exit Sub

    For Each Sheet In Sheets
        If Sheet.Name <> "SEARCH" Then
            With Sheet.Columns(1)
                Set Cell = .Find(WhatFor, LookIn:=xlValues, LookAt:=xlPart)
                If Not Cell Is Nothing Then
                    FirstAddress = Cell.Address
                    Do
                        Cell.EntireRow.Copy _
                        Destination:=Sheets("SEARCH").Range("A" & Rows.Count).End(xlUp).Offset(1, 0)
                        Set Cell = .FindNext(Cell)
                    Loop Until Cell Is Nothing Or Cell.Address = FirstAddress
                End If
            End With
        End If
    Next Sheet

    Set Cell = Nothing
End Sub

Any help will be appreciated. 任何帮助将不胜感激。 Thank you. 谢谢。

For one sheet, this is easy to accomplish with a formula alone, eg 对于一张纸,仅使用公式即可轻松完成,例如

= INDEX(1:1,MATCH("yes",5:5,0))

This finds the first instance of yes in the 5th row of the current sheet, and returns the value in 1st row and in the same column. 这将在当前工作表的第5行中找到yes的第一个实例,并在第1行和同一列中返回值。

One option is to have this formula above somewhere on each sheet in your workbook as a "helper cell" (eg cell Z99 ) and then have a formula somewhere on your master sheet to check all of these helper cells, eg 一种选择是将此公式放在工作簿中每个工作表上方的某个地方作为“帮助单元格”(例如,单元格Z99 ),然后在您的母版工作表中某个地方的某个位置,以检查所有这些帮助单元格,例如

= IFERROR(Sheet1!Z99,IFERROR(Sheet2!Z99,IFERROR(Sheet3!Z99,IFERROR(...,"no match"))))

Of course, also possible without helper cells at all, but the formula just gets messy: 当然,完全没有辅助单元也是可能的,但是公式变得混乱:

= IFERROR(INDEX(Sheet1!1:1,MATCH("yes",Sheet1!5:5,0)),
  IFERROR(INDEX(Sheet2!1:1,MATCH("yes",Sheet2!5:5,0)),
  IFERROR(INDEX(Sheet3!1:1,MATCH("yes",Sheet3!5:5,0)),
  IFERROR(...,"no match"))))

If you want a way without explicitly calling each sheet, then VBA is probably required. 如果您想要一种方法而无需显式调用每个工作表,则可能需要VBA。 Just posting a solution without VBA to see if this will work for you. 只需发布不带VBA的解决方案,看看是否适合您。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Excel:如果列中的单元格= X的文本值,则在另一个工作表上显示文本(在同一行,但不同的列) - Excel: If Cell in Column = text value of X, then display text (in the same row, but different column) on another sheet 在Excel数组中查找文本的完全匹配项(从另一张表中查找),并在同一行中显示特定的单元格值 - Find exact match of text in excel array (from another sheet) and display a specific cell value from the same row VBA - 获取工作表中值的行号,然后将不同的值插入同一行的不同列 - VBA - Get row number of a value in a sheet, and then insert a different value into a different column of that same row 如何在Excel工作表中查找值,然后使用openpyxl在同一行的不同单元格中写入另一个值 - How to find a value in excel sheet and then write another value in a different cell in the same row with openpyxl 我需要创建一个公式,如果其中一列中有一个值,则将同一值的整个行复制到另一张纸上 - I need to create a formula where if a column has a value in it the entire row of that same value gets copied to a different sheet 根据特定的列值,将单个Excel工作表转换为多个工作表 - Single Excel Sheet to Multiple Sheets, based on specific column value 在其他工作表中查找一列的最大值,并在结果表中报告 - Find Maximum Value for a column in different sheets and report it in result sheet 如果在列上找到值,则在同一行上写入数据 - if value is found on a column write data on the same row 将工作表1 A列中的值匹配工作表2 A列中的值,如果找不到值,则删除该行 - Match value from sheet 1 A column to sheet 2 A column and delete the row if A value is not found 迭代excel表中特定列号的所有行,并对每个行值进行一些处理 - Iterate all rows of a specific column number in excel sheet and do some processing on each row value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM