|
发表于 2015-10-20 18:16
|
显示全部楼层
本楼为最佳答案
误解了你的意思,看这个附件- Sub test()
- Dim n%, x%, y%, arr, arr2
- n = Application.InputBox("请输入数字", , , , , , , 1)
- If Application.WorksheetFunction.CountIf([a:a], n) = 0 Then MsgBox "无该数据,请重试": Exit Sub
- arr = Range("a1", Range("a65536").End(xlUp))
- ReDim arr2(1 To UBound(arr), 1 To 1)
- For x = 1 To UBound(arr)
- If arr(x, 1) = n Then
- y = y + 1
- arr2(y, 1) = arr(x + 1, 1)
- End If
- Next x
- [b:b].ClearContents
- [b1].Resize(y) = arr2
- End Sub
复制代码 |
|