|
- Sub Test()
- Dim shSource As Worksheet, shResult As Worksheet
- Dim arrSource As Variant
- Dim lngRow As Long
- Dim rgFind As Range, rg As Range
- Dim blIsRED As Boolean, lngRowID As Long
-
- Set shSource = Sheets("Sheet1")
- Set shResult = Sheets("Sheet2")
-
- arrSource = shSource.UsedRange
-
- shResult.UsedRange.ClearContents
- shResult.Cells.Font.Size = 9
- shResult.Range("B:B").NumberFormatLocal = "@"
- '列标题
- shResult.Range("A1").Resize(1, UBound(arrSource, 2)) = Application.WorksheetFunction.Index(arrSource, 1, 0)
- lngRowID = 2
-
- For lngRow = 2 To UBound(arrSource)
- Set rgFind = Union(shSource.Range("N" & lngRow & ":O" & lngRow), shSource.Range("AC" & lngRow & ":AD" & lngRow))
- blIsRED = False
- For Each rg In rgFind
- If rg.Font.ColorIndex = 3 Or rg.Interior.ColorIndex = 3 Then
- blIsRED = True
- Exit For
- End If
- Next
-
- If blIsRED = True Then
- shResult.Range("A" & lngRowID).Resize(1, UBound(arrSource, 2)) = Application.WorksheetFunction.Index(arrSource, lngRow, 0)
- lngRowID = lngRowID + 1
- End If
- Next
-
- MsgBox "成功提取数据【" & lngRowID - 2 & "】条"
- End Sub
复制代码 |
|