Re: [問題] 請問如何將excel中的文字做對應(VBA)
這類問題我是習慣用 VBA 解,VBA 的使用方法請查之前的文章
Option Explicit
Sub Marco1()
Dim index As Integer, index2 As Integer, index3 As Integer
Dim rLast As Integer
rLast = Cells.Find(What:="*", After:=[A1], SearchDirection:=xlPrevious).row
index3 = 1
For index = 1 To rLast
For index2 = 1 To Len(Cells(index, 1))
Cells(index3, 3) = Mid(Cells(index, 1), index2, 1)
Cells(index3, 4) = Cells(index, 2)
index3 = index3 + 1
Next index2
Next index
MsgBox ("成功")
End Sub
※ 引述《dolphinbabys (dolphinbabys)》之銘言:
: 軟體: excel
: 版本:2003
: 請問要如何將excel儲存格中的文字(每格字數從1~5不等)拉出來成為一行?
: 其實本來的格式是:
: A B
: 1 我 1
: 2 今天 2
: 3 跟 1
: 4 朋友 2
: 5 去 2
: 6 陽明山 2
: A欄是文字欄, B欄是後加上去的標記欄.
: 現在因為搜尋的需要, 希望把這個格式變成:
: A B
: 1 我 1
: 2 今 2
: 3 天 2
: 4 跟 1
: 5 朋 2
: 6 友 2
: 7 去 2
: 8 陽 2
: 9 明 2
: 10 山 2
: 就是不僅是要把A欄所有文字變成一字一格, 最好也能將B欄對應的標記一起放上去,
: (如"陽明山" 這三個字變成三格, 且三格的標記都是原來的"2")
: 不知道這個是否可以在excel裡面辦到?或是利用word和excel的互相應用?
: 目前唯一想得到的辦法是手動插入儲存格且打上對應標記,
: 可是因為檔案有上萬筆, 不知道是否有更快的方式呢?
: 謝謝!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.229.77.74
Office 近期熱門文章
PTT數位生活區 即時熱門文章