Re: [VBA ] 如何做到多筆轉置?

看板Visual_Basic作者 (矇面加菲獅)時間19年前 (2006/05/20 08:30), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
方向應該是這樣,對吧@@ 原始 目的 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
文章代碼(AID): #14RcCDAr (Visual_Basic)
文章代碼(AID): #14RcCDAr (Visual_Basic)