|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
Sub 查询()
Application.ScreenUpdating = False
Dim ar As Variant, br As Variant
Dim i As Long, r As Long
Dim d As Object
Set d = CreateObject("scripting.dictionary")
With Sheets("A表")
r = .Cells(Rows.Count, 1).End(xlUp).Row
If r < 2 Then MsgBox "A表为空!": End
ar = .Range(.Cells(1, 1), .Cells(r, 17))
End With
sr = InputBox("请输入月计划号进行查询", "月计划号", "8033")
If sr = "" Then End
With Sheets("B表")
.UsedRange.Offset(1) = Empty
br = .Range("a1:s" & r)
For j = 1 To UBound(br, 2)
If br(1, j) <> Empty Then
d(br(1, j)) = j
End If
Next j
n = 1
For i = 2 To UBound(ar)
If ar(i, 2) = Val(sr) Then
n = n + 1
For j = 1 To UBound(ar, 2)
lh = d(ar(1, j))
If lh <> "" Then
br(n, lh) = ar(i, j)
End If
Next j
End If
Next i
If n = 1 Then MsgBox "没有符合条件的数据!": End
.[a1].Resize(n, UBound(br, 2)) = br
End With
Application.ScreenUpdating = True
MsgBox "ok!"
End Sub
|
评分
-
1
查看全部评分
-
|