返回列表 上一主題 發帖

[轉貼] VBA的寫作技巧與增進效能

從此文章學到精華,這些簡化方式在各先進提供解答中
都可以學到,經由此篇更精華吸收,感恩
總是利用巨集錄製,再依學習到的VBA語法
想想怎麼簡化,來到這看看其他人的寫法
再看看以前寫的,總是可以學到一些
像是單純現存數據,以前總是犯了選取cells
再處理,近日學到一些,針對利用處理數據
寫了一段處理格式的語法
目前處理資料尚可,但一直持續學習簡化增進效能技巧中
關於Application.ScreenUpdating 學到,正在運用簡化中
目前正在學習如何簡化,如果有簡化idea 煩請提供供學習,感恩

KRowEnd = Cells(Rows.Count, 1).End(xlUp).Row '以 A欄資料為基礎 =1 判斷範圍
kcolend = Cells(1, Columns.Count).End(xlToLeft).Column '以 第一列資料為基礎 =1判斷判斷範圍

MsgBox "列數KRowEnd=" & KRowEnd
MsgBox "欄數kcolend=" & kcolend

Range(Cells(1, 1), Cells(1, kcolend)).Select

    With Selection.Interior
        .ColorIndex = 36 '淺黃色
        .Pattern = xlSolid
    End With
    Selection.Font.ColorIndex = 3


Range(Cells(2, 1), Cells(KRowEnd, kcolend)).Select

    ActiveWindow.FreezePanes = True
    Selection.FormatConditions.Delete
    Selection.FormatConditions.Add Type:=xlExpression, Formula1:= _
        "=MOD(ROW(),2)"
    Selection.FormatConditions(1).Interior.ColorIndex = 15
Range(Cells(1, 1), Cells(1, kcolend)).Select
    Selection.AutoFilter
    Cells.EntireColumn.AutoFit

TOP

        靜思自在 : 【為善競爭】人生要為善競爭,分秒必爭。
返回列表 上一主題