发布网友 发布时间:2022-04-23 03:52
共1个回答
热心网友 时间:2023-10-13 21:52
Sub q()
Dim InStrs As String
InStrs = InputBox("请输入你需要查询的硬件版本号:", "硬件版本号&型号定位宏")
Dim Row, J, I As Integer, outStr() As String
Row = Sheet1.Cells(Sheet1.Rows.Count, 13).End(xlUp).Row
ReDim outStr(0)
With Sheet1
For I = 2 To Row
If .Cells(I, 14) = InStrs Then
ReDim Preserve outStr(UBound(outStr) + 1)
outStr(UBound(outStr)) = .Cells(I, 13)
End If
Next I
End With
With Sheet2
For J = 1 To UBound(outStr)
.Cells(J + 1, 4) = J
.Cells(J + 1, 5) = outStr(J)
Next J
End With
End Sub
追问这个刚才验证了一下,只有一个对话框出来,输入数字,然后点确定,就没有任何反应,不过还是十分感谢
追答是否是sheet1和sheet2以及列的位置,要根据你的实际情况修改的。