|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 提取()
Dim wt As Worksheet
Dim i As Integer
Set wt = ThisWorkbook.Worksheets(2)
j = 1
For i = 1 To wt.UsedRange.Rows.Count
If Abs(wt.Cells(i, 1).Value - wt.Cells(i, 2).Value) <= 2 Then
ThisWorkbook.Worksheets(3).Cells(j, 1) = wt.Cells(i, 1)
ThisWorkbook.Worksheets(3).Cells(j, 2) = wt.Cells(i, 2)
ThisWorkbook.Worksheets(3).Cells(j, 3) = wt.Cells(i, 1).Address(0, 0) '里面输入0,0就会输出A1格式。还有xlA1和xlR1C1格式。
ThisWorkbook.Worksheets(3).Cells(j, 4) = wt.Cells(i, 2).Address(0, 0)
j = j + 1
End If
Next
Set wt = Nothing
End Sub |
|