|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub test()
- Dim r&, i&
- Dim arr, brr
- With Worksheets("查询窗口")
- sfz = .Range("b2")
- End With
- With Worksheets("基础数据")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- arr = .Range("a2:g" & r)
- For i = 1 To UBound(arr)
- If arr(i, 2) = sfz Then
- Exit For
- End If
- Next
- End With
- If i <= UBound(arr) Then
- With Worksheets("查询窗口")
- .Columns(2).NumberFormatLocal = "@"
- .Range("a2").Resize(1, UBound(arr, 2)) = Application.Index(arr, i, 0)
- End With
- Else
- MsgBox "没有查询到符合条件数据!"
- End If
- End Sub
复制代码 |
|