標題:
[發問]
如何排出帶有文字和數字資料
[打印本頁]
作者:
luke
時間:
2012-3-29 22:45
標題:
如何排出帶有文字和數字資料
小弟碰到乙個帶有文字和數字問題, 因資料常常作變更, 我想用VBA依序排出, 放入Sheet2中
麻煩請教先進!!
[attach]10214[/attach]
作者:
chin15
時間:
2012-3-29 23:15
Option Explicit
Sub test()
Dim n%, c%, i%, j%, m%, arr(), rng
n = [a65536].End(3).Row
c = [iv1].End(1).Column
rng = [a1].Resize(n, c)
For i = 2 To c
For j = 2 To n
If rng(j, i) <> "" Then
m = m + 1
ReDim Preserve arr(1 To 3, 1 To m)
arr(1, m) = rng(1, i)
arr(2, m) = rng(j, 1)
arr(3, m) = rng(j, i)
End If
Next
Next
Sheet2.[a1].Resize(m, 3) = Application.Transpose(arr)
End Sub
複製代碼
作者:
Hsieh
時間:
2012-3-29 23:22
Sub ex()
Dim Ay()
ar = Range("A1").CurrentRegion
For i = 2 To UBound(ar, 2)
For j = 2 To UBound(ar, 1)
If ar(j, i) <> "" Then
ReDim Preserve Ay(s)
Ay(s) = Array(ar(1, i), ar(j, 1), ar(j, i))
s = s + 1
End If
Next
Next
[S1].Resize(s, 3) = Application.Transpose(Application.Transpose(Ay))
End Sub
複製代碼
回復
1#
luke
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)