|
Sub 提取数据()
Dim iRow&, iCol&, tRng As Range
Dim ww As Workbook
Dim sh As Worksheet
Set ww = ThisWorkbook
Set sh = ww.Worksheets(1)
Set Sht = ww.Worksheets(2)
iRow = sh.Cells(Rows.Count, 2).End(xlUp).Row
arr = sh.Range("a1:y" & iRow)
For i = 6 To UBound(arr)
If arr(i, 13) = "水果" Then
If Not tRng Is Nothing Then
Set tRng = Union(tRng, sh.Range(sh.Cells(i, 2), sh.Cells(i, UBound(arr, 2))))
Else
Set tRng = Range(sh.Cells(i, 2), sh.Cells(i, UBound(arr, 2)))
End If
End If
Next i
If tRng Is Nothing Then
sh.Cells(6, 2).Select
MsgBox "没发现水果!", 48
Else
tRng.Copy Sht.[b6]
MsgBox "完成", 64
End If
Sht.Activate
End Sub
|
|