
Sub adress() Dim keypos_A, keypos_B As Integer Dim i As Integer For i = 2 To 999 keypos_A = InStr(Cells(i, "A"), "和") keypos_B = InStr(Cells(i, "A"), "安") If keypos_A <> 0 And keypos_B <> 0 Then Cells(i, "B") = Mid(Cells(i, "A"), keypos_A, 1) Cells(i, "C") = Mid(Cells(i, "A"), keypos_B, 1) Cells(i, "D") = Cells(i, "A") End If If Cells(i, "A") = "" Then MsgBox "迴圈計算至" & i - 1 & "筆後結束" Exit For End If Next End Sub









範例程式如下: