想請教以下這一段程式是否有執行起來比較快的寫法 ?
我只是想參考看看不同的程式寫法.
感謝...
For fcsty = 4 To put_rownum
If .Cells(fcsty, "B") <> "" And Not .Cells(fcsty, "A") Like "*合計" Then
' 增加判斷 "B"欄為空白, 或是保留 "合計" 的列.
If .Cells(fcsty, hid_colnum) < put_maxnum And .Cells(fcsty, hid_colnum) > put_minnum Then
.Rows(fcsty).Hidden = True
End If
End If
Next
End With
_________________________________________
整段程式
Sub ProductsQ1FP()
ActiveSheet.PivotTables("樞紐分析表1").PivotFields("Group").ClearAllFilters
ActiveWindow.FreezePanes = False ' 取消凍結視窗
Dim put_rownum As Integer
Dim hid_colnum As Integer
ActiveSheet.Rows.Hidden = False '取消所有的隱藏
ActiveSheet.Range("c4").Select '游標放在c4
ActiveWindow.FreezePanes = True '凍結視窗
ActiveWindow.ScrollColumn = 3 '凍結列與欄的視窗
ActiveSheet.PivotTables("樞紐分析表1").PivotFields("Group").AutoSort xlDescending, _
"加總 的Q1F-P"
put_rownum = ActiveSheet.Range("c2").Value '最後一列
put_maxnum = ActiveSheet.Range("b1").Value '大於
put_minnum = ActiveSheet.Range("b2").Value '小於
hid_colnum = ActiveSheet.Range("f1").Value '排序欄
With ActiveSheet
.Cells(4, hid_colnum).Select '游標放置點
For fcsty = 4 To put_rownum
If .Cells(fcsty, "B") <> "" And Not .Cells(fcsty, "A") Like "*合計" Then
' 增加判斷 "B"欄為空白, 或是保留 "合計" 的列.
If .Cells(fcsty, hid_colnum) < put_maxnum And .Cells(fcsty, hid_colnum) > put_minnum Then
.Rows(fcsty).Hidden = True
End If
End If
Next
End With
End Sub作者: register313 時間: 2012-6-16 10:59