返回列表 上一主題 發帖

可否請各位先進幫我簡化代碼

可否請各位先進幫我簡化代碼

可以請各位先進幫小弟簡化代碼,讓他執行快一點,到後面50幾行就很慢了,謝謝各位...


Private Sub jump123()
For a = 2 To 10000
  If Cells(a, 1) = "" Then Exit For
    s = Cells(a, 4)

If s Like "201106*" Then
        Cells(a, 5) = "A"
End If
If s Like "201101*" Then
        Cells(a, 5) = "B"
End If
If s Like "201111*" Then
        Cells(a, 5) = "C"
End If
If s Like "201102*" Then
        Cells(a, 5) = "D"
End If
If s Like "201127*" Then
        Cells(a, 5) = "E"
End If
If s Like "1101*" Then
        Cells(a, 5) = "F"
End If
If s Like "1102*" Then
        Cells(a, 5) = "G"
End If
If s Like "1103*" Then
        Cells(a, 5) = "H"
End If
If s Like "1104*" Then
        Cells(a, 5) = "I"
End If
If s Like "1105*" Then
        Cells(a, 5) = "J"
End If
If s Like "1106*" Then
        Cells(a, 5) = "K"
End If
If s Like "1107*" Then
        Cells(a, 5) = "L"
End If
If s Like "1108*" Then
        Cells(a, 5) = "M"
End If
If s Like "1109*" Then
        Cells(a, 5) = "N"
End If
If s Like "1110*" Then
        Cells(a, 5) = "O"
End If
If s Like "1111*" Then
        Cells(a, 5) = "P"
End If
If s Like "1112*" Then
        Cells(a, 5) = "Q"
End If
If s Like "1113*" Then
        Cells(a, 5) = "R"
End If
If s Like "1114*" Then
        Cells(a, 5) = "S"
End If
If s Like "1115*" Then
        Cells(a, 5) = "T"
End If
If s Like "1116*" Then
        Cells(a, 5) = "U"
End If
If s Like "1117*" Then
        Cells(a, 5) = "V"
End If
If s Like "1118*" Then
        Cells(a, 5) = "X"
End If
If s Like "1119*" Then
        Cells(a, 5) = "Y"
End If
If s Like "1120*" Then
        Cells(a, 5) = "Z"
End If

   Next a

End Sub

本帖最後由 fyo00241 於 2011-12-29 01:13 編輯

感謝2位大大的分享,我再貼上我後來的代碼,請2位幫我簡化一下,因為速度到後面就很慢了我key條碼它判斷時就會lag了,先感謝2位了!!
arr = [d2:d10000]
For i = 1 To UBound(arr)
    s = arr(i, 1)
    If s Like "201106*" Then
        brr(i) = "手打鐘Ⅰ"

ElseIf s Like "201101*" Then
        brr(i) = "手打鐘"

ElseIf s Like "201111*" Then
        brr(i) = "手打鐘Ⅱ"

ElseIf s Like "201102*" Then
        brr(i) = "手打鐘"
        
ElseIf s Like "201103*" Then
        brr(i) = "手打鐘"

ElseIf s Like "201127*" Then
        brr(i) = "T27印表機"

ElseIf s Like "1101*" Then
        brr(i) = "中文鴿鐘"

ElseIf s Like "1102*" Then
        brr(i) = "英文鴿鐘"

ElseIf s Like "1103*" Then
        brr(i) = "中文語音鴿鐘"

ElseIf s Like "1104*" Then
        brr(i) = "英文語音鴿鐘"

ElseIf s Like "1105*" Then
        brr(i) = "中文語音鴿鐘(G)"

ElseIf s Like "1106*" Then
        brr(i) = "英文語音鴿鐘(G)"

ElseIf s Like "1107*" Then
        brr(i) = "凹槽"

ElseIf s Like "1108*" Then
        brr(i) = "CI"

ElseIf s Like "1109*" Then
        brr(i) = "單格15PIN"

ElseIf s Like "1110*" Then
       brr(i) = "單格9PIN"

ElseIf s Like "1111*" Then
        brr(i) = "四合一15PIN-E"

ElseIf s Like "1112*" Then
        brr(i) = "四合一15PIN-EL"

ElseIf s Like "1113*" Then
        brr(i) = "四合一9PIN"

ElseIf s Like "1114*" Then
        brr(i) = "GPS(方形)"

ElseIf s Like "1115*" Then
        brr(i) = "525電匠"

ElseIf s Like "1116*" Then
        brr(i) = "747電匠"

ElseIf s Like "1117*" Then
        brr(i) = "T+1感應板"

ElseIf s Like "1118*" Then
        brr(i) = "傳訊機5V"

ElseIf s Like "1119*" Then
        brr(i) = "傳訊機非5V"

ElseIf s Like "1120*" Then
        brr(i) = "UID讀碼機"
End If
           
   
Next
[E2].Resize(999, 1) = Application.WorksheetFunction.Transpose(brr)

TOP

本帖最後由 fyo00241 於 2011-12-29 08:56 編輯

日記帳記錄.zip (832.98 KB)
回復 5# register313
麻請了是UserForm1這個地方,也請大大幫我看一下那些地方可以再簡化,順一點的謝謝了!!

TOP

本帖最後由 fyo00241 於 2011-12-29 21:43 編輯

回復 8# GBKEE


報告G大:3543

TOP

本帖最後由 fyo00241 於 2011-12-30 00:36 編輯
回復  fyo00241

請問原來的程式是否能正常執行 好多地方有問題

只修正本帖所提之執行速度
試試看
...
register313 發表於 2011-12-29 18:52


大大我無法下載附件......
[email protected]也無法發短消息@_@

TOP

大大我無法下載附件......
也無法發短消息@_@
fyo00241 發表於 2011-12-29 21:42

感謝大大,目前我會測試一下,文件我收到了,謝謝喔!!

TOP

回復  fyo00241
簡化 UserForm1各單位工作表的Worksheet_Change 可刪除置於ThisWorkbook 中
GBKEE 發表於 2012-1-1 09:31


感謝大大幫忙,又學了很多,我來試看看,,希望可以再幫我看一下那裡要改的...先謝謝了!!

TOP

回復  fyo00241

是不是先把之前修改過的作個測試
說明一下功能有沒有問題(那邊有問題)  操作速度正不正 ...
register313 發表於 2012-1-2 23:39


大大你之前改的我測了一下可以的速度可以接受了!!

TOP

回復  register313
說明一下功能有沒有問題(那邊有問題)  操作速度正不正常
樓主檔案較大,所以執行程式速 ...
GBKEE 發表於 2012-1-3 08:22


大大你說的資料庫部份是如何做較好呢??

TOP

回復  GBKEE


    自己改的 不知如何
register313 發表於 2012-1-3 08:28



    大大再麻煩你寄給我,謝謝了!

TOP

        靜思自在 : 人生沒有所有權,只有生命的使用權。
返回列表 上一主題