文章预览
学习Excel技术,关注微信公众号: excelperfect 标签: VBA 下面的示例搜索工作簿中除工作表“汇总表”外的多个工作表中的数据,将满足条件的数据所在行复制到指定工作表。 Sub SearchAndCombineSheets() Dim FirstAddress As String Dim WhatFor As String Dim c As Range Dim ws As Worksheet WhatFor = InputBox("搜索什么数据?", "搜索条件") If WhatFor = Empty Then Exit Sub For Each ws In Worksheets If ws.Name < > "汇总表" Then With ws.Columns(7) Set c = .Find(WhatFor, LookIn:=xlValues, LookAt:=xlPart) If Not c Is Nothing Then FirstAddress = c.Address Do If c.EntireRow.Cells(1, 6).Value > 0 Then c.EntireRow.Copy Destination : =Worksheets("汇总表").Range("A" & Rows.Count).End(xlUp).Offset(1, 0) End If Set c = .FindNext(c)
………………………………