作者fumizuki (蒙面加菲狮)
看板Visual_Basic
标题Re: [VBA ] 如何做到多笔转置?
时间Sat May 20 09:02:01 2006
方向应该是这样,对吧@@
原始 目的
A B C D E F G H A B C D E F G H
1 11 1 11 12 13 14 15
2 12 2 21 22 23 24 25
3 13 3
4 14 4
5 15 5
6 21 6
7 22 7
8 23 8
9 24 9
10 25 10
Private Sub CommandButton1_Click()
Dim RowIndex As Integer, RecIndex As Integer, ColIndex As Integer
Dim Src As String, Dest As String, SrcUBound As Long
SrcUBound = Val(InputBox("请输入资料数量"))
RowIndex = 0: RecIndex = 1: ColIndex = 0
'开始转换资料
Do
If ColIndex = 5 Then ColIndex = 0: RecIndex = RecIndex + 1
ColIndex = ColIndex + 1
RowIndex = RowIndex + 1
Src = "A" & RowIndex
Dest = Chr(ColIndex + 64) & RecIndex
Range(Dest).Value = Range(Src).Value
Loop While RowIndex < SrcUBound
'清除原始资料
Src = "A" & (RecIndex + 1)
Dest = "A" & SrcUBound
Range(Src & ":" & Dest).Clear
MsgBox "资料转换完成,共" & RecIndex & "列资料", vbInformation
End Sub
--
做资料转换前,原始资料要记得备份
--
▃▅▇▆▄ ▆▂▃ `
逝去感情如何能留住,半点痴情遗留殊不易,██▅▇▄▃ ▇▃▂" .
█████████▃i ▁▄▇
更多凄凄惨惨的遭遇…………██▆▃ █▅▆▃ˍ▄*
◢ ▂█▄▇▅▂▌.
我不知道,王~八~蛋~~! ▂▆███ █▄▃ 。fumizuki。Check。
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 210.58.156.43