|
发表于 2013-4-5 00:09
|
显示全部楼层
本楼为最佳答案
本帖最后由 hwc2ycy 于 2013-4-5 00:29 编辑
- Sub 提取数据()
- Dim lrow&, arr
- lrow = Cells(Rows.Count, "i").End(xlUp).Row
- arr = Range("i5:bv" & lrow)
- Dim str$
- Dim k&, i&
- k = UBound(arr)
- For i = LBound(arr, 2) To UBound(arr, 2)
- If VBA.IsNumeric(arr(k, i)) Then
- str = str & i & ","
- End If
- Next
- If Len(str) > 0 Then
- str = Left(str, Len(str) - 1)
- Dim arrPos
- arrPos = Split(str, ",")
- Dim result()
- ReDim result(1 To k, 1 To UBound(arrPos) + 1)
- For i = LBound(arr) To UBound(arr)
- For k = LBound(result, 2) To UBound(result, 2)
- result(i, k) = arr(i, arrPos(k - 1))
- Next
- Next
- Sheet2.Range("a1").Resize(i - 1, k - 1) = result
- MsgBox "OK!"
- End If
- End Sub
复制代码 |
|