Board logo

標題: [發問] 程式碼簡化(VB執行時間過久) [打印本頁]

作者: liebe    時間: 2017-7-12 18:44     標題: 程式碼簡化(VB執行時間過久)

各位大大們好!
由於VB程式執行時間太久,所以想請教各位該如何
以下程式碼為錄製巨集出現
請問要如何更改 才能使執行起來順一點,不然會一直選取下拉方塊作更改,因為下拉放塊總共有284個,如果每個都這樣定義,程式執行時間會超級久
如果以單純定義下拉方塊的"輸入範圍"與"儲存格連結"的話,有何方法可以簡化的呢?
謝謝大家!
部分程式碼如下:
ActiveSheet.Shapes.Range(Array("Drop Down 322")).Select
    With Selection
        .ListFillRange = "control"
        .LinkedCell = "A21"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 340")).Select
    With Selection
        .ListFillRange = "Son"
        .LinkedCell = "C21"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 323")).Select
    With Selection
        .ListFillRange = "control"
        .LinkedCell = "A22"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 341")).Select
    With Selection
        .ListFillRange = "Stw"
        .LinkedCell = "C22"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 324")).Select
    With Selection
        .ListFillRange = "control"
        .LinkedCell = "A23"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 342")).Select
    With Selection
        .ListFillRange = "Sthr"
        .LinkedCell = "C23"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 325")).Select
    With Selection
        .ListFillRange = "control"
        .LinkedCell = "A24"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveWindow.SmallScroll Down:=6
    ActiveSheet.Shapes.Range(Array("Drop Down 335")).Select
    With Selection
        .ListFillRange = "Sfo"
        .LinkedCell = "C24"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 354")).Select
    With Selection
        .ListFillRange = "control"
        .LinkedCell = "A25"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 355")).Select
    With Selection
        .ListFillRange = "Sfi"
        .LinkedCell = "C25"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 327")).Select
    With Selection
        .ListFillRange = "control"
        .LinkedCell = "A26"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 336")).Select
    With Selection
        .ListFillRange = "Ssi"
        .LinkedCell = "C26"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 328")).Select
    With Selection
        .ListFillRange = "control"
        .LinkedCell = "A27"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 347")).Select
    With Selection
        .ListFillRange = "Sse"
        .LinkedCell = "C27"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 334")).Select
    With Selection
        .ListFillRange = "control"
        .LinkedCell = "A28"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 346")).Select
    With Selection
        .ListFillRange = "Sei"
        .LinkedCell = "C28"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 348")).Select
    With Selection
        .ListFillRange = "control"
        .LinkedCell = "A29"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 349")).Select
    With Selection
        .ListFillRange = "Sni"
        .LinkedCell = "C29"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 330")).Select
    With Selection
        .ListFillRange = "control"
        .LinkedCell = "A30"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 344")).Select
    With Selection
        .ListFillRange = "Ste"
        .LinkedCell = "C30"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 333")).Select
    With Selection
        .ListFillRange = "control"
        .LinkedCell = "A31"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 339")).Select
    With Selection
        .ListFillRange = "Sel"
        .LinkedCell = "C31"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 332")).Select
    With Selection
        .ListFillRange = "control"
        .LinkedCell = "A32"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 338")).Select
    With Selection
        .ListFillRange = "Stwef"
        .LinkedCell = "C32"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 331")).Select
    With Selection
        .ListFillRange = "control"
        .LinkedCell = "A33"
        .DropDownLines = 8
        .Display3DShading = True
    End With
    ActiveSheet.Shapes.Range(Array("Drop Down 337")).Select
    With Selection
        .ListFillRange = "Sthrt"
        .LinkedCell = "C33"
        .DropDownLines = 8
        .Display3DShading = True
End With
作者: qekqo    時間: 2017-7-16 00:21

看不太懂您的題意~ 方便的話請附檔說明 ^^




歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)