標題:
[發問]
do loop 求助
[打印本頁]
作者:
l394244
時間:
2013-8-25 17:42
標題:
do loop 求助
各位大大好~
小的第一次學VBA.. 目前卡在 do Loop 迴圈問題,提示:沒有do 有LOOP。
盯了螢幕許久,還是找不出錯誤所在 ORZ... 還懇請各位高手們幫忙找出錯誤,如果可以還請大大逐列說明 非常感謝 !
以下是小的從書上進行改寫 :
Sub 代號()
C = 2
Do While Cells(C, 1) <> ""
Select Case Cells(C, 1)
Case "0015"
Cells(2, C) = "1台北"
Select Case Cells(C, 1)
Case "0048"
Cells(2, C) = "2城東"
Select Case Cells(C, 1)
Case "0059"
Cells(2, C) = "4新莊"
Select Case Cells(C, 1)
Case "0060"
Cells(2, C) = "7新竹"
Select Case Cells(C, 1)
Case "0082"
Cells(2, C) = "a高雄"
Select Case Cells(C, 1)
Case "0118"
Cells(2, C) = "3信義"
Select Case Cells(C, 1)
Case "1366"
Cells(2, C) = "8台中"
Select Case Cells(C, 1)
Case "0152"
Cells(2, C) = "9台南"
Select Case Cells(C, 1)
Case "1171"
Cells(2, C) = "5板橋"
Select Case Cells(C, 1)
Case "0185"
Cells(2, C) = "6桃園"
Select Case Cells(C, 1)
Case "0451"
Cells(2, C) = "b羅東"
Select Case Cells(C, 1)
Case "0875"
Cells(2, C) = "C忠孝"
Select Case Cells(C, 1)
Case "0680"
Cells(2, C) = "E 南台中"
Select Case Cells(C, 1)
Case ""
Cells(2, C) = "未定義"
End Select
C = C + 1
Loop
End Sub
作者:
sunnyso
時間:
2013-8-25 17:50
不需要那麽多select casr
作者:
l394244
時間:
2013-8-25 18:24
謝謝大大指點~
小妹剛剛發現所撰寫的程式有矛盾,我再回去修改研究
作者:
GBKEE
時間:
2013-8-28 14:52
回復
1#
l394244
Option Explicit
Sub 代號()
Dim C As Integer
C = 2
Do While Cells(C, 1) <> ""
Select Case Cells(C, 1)
Case "0015"
Cells(2, C) = "1台北"
Case "0048"
Cells(2, C) = "2城東"
Case "0059"
Cells(2, C) = "4新莊"
Case "0060"
Cells(2, C) = "7新竹"
Case "0082"
Cells(2, C) = "a高雄"
Case "0118"
Cells(2, C) = "3信義"
Case "1366"
Cells(2, C) = "8台中"
Case "0152"
Cells(2, C) = "9台南"
Case "1171"
Cells(2, C) = "5板橋"
Case "0185"
Cells(2, C) = "6桃園"
Case "0451"
Cells(2, C) = "b羅東"
Case "0875"
Cells(2, C) = "C忠孝"
Case "0680"
Cells(2, C) = "E 南台中"
Case Else ' ""
Cells(2, C) = "未定義"
End Select
C = C + 1
Loop
End Sub
複製代碼
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)