我有超过20多个标签的大型电子表格。每个标签具有相同的结构
A=ref,B= Discipline, C=Location, D=item/location, E=Defect, F=Date, G=%complete
我想要做的是在整个工作簿中搜索G列,并返回未列出“100”的所有项目的列表。结果将显示在摘要页面上。
随着时间的推移,项目列表会变得更小,因为更多的100输入到G列。
你能告诉我怎么做吗? 谢谢
答案 0 :(得分:0)
您可以在VBA中使用Range.Find方法。
https://msdn.microsoft.com/en-us/library/office/ff839746.aspx
这假定A列中总会存在某些内容并将A:G列复制到名为Summary
的工作表中Sub Find100Percent()
Dim wrkSht As Worksheet
Dim rFoundCell As Range
Dim sFirstAddress As String
Dim shtSummary As Worksheet
Set shtSummary = ThisWorkbook.Worksheets("Summary")
For Each wrkSht In ThisWorkbook.Worksheets
If wrkSht.Name <> shtSummary.Name Then
With wrkSht.Columns(7)
Set rFoundCell = .Find(1, LookIn:=xlValues)
If Not rFoundCell Is Nothing Then
sFirstAddress = rFoundCell.Address
Do
rFoundCell.Offset(, -6).Resize(, 7).Copy _
shtSummary.Cells(shtSummary.Rows.Count, 1).End(xlUp).Offset(1)
Set rFoundCell = .FindNext(rFoundCell)
Loop While Not rFoundCell Is Nothing And rFoundCell.Address <> sFirstAddress
End If
End With
End If
Next wrkSht
End Sub