標題:
如何簡化這程式
[打印本頁]
作者:
hong912
時間:
2014-11-13 23:58
標題:
如何簡化這程式
大大們, 安好,
小弟錄制了一個巨集, 但錄制出來的程式太長, 請教大大們, 如何把程式簡化, 感恩, 謝謝!!
Sub 清除工作表色彩()
'
' 清除工作表色彩 Macro
'
'
Sheets("1月").Select
Range("G4").Select
Range("G4:AK20").Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("G4").Select
Sheets("2月").Select
Range("G4:AK20").Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("G4").Select
Sheets("3月").Select
Range("G4:AK20").Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("G4").Select
Sheets("4月").Select
Range("G4:AK20").Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("G4").Select
Sheets("5月").Select
Range("G4:AK20").Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("G4").Select
Sheets("6月").Select
Range("G4:AK20").Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("G4").Select
Sheets("7月").Select
Range("G4:AK20").Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("G4").Select
Sheets("8月").Select
Range("G4:AK20").Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("G4").Select
Sheets("9月").Select
Range("G4:AK20").Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("G4").Select
Sheets("10月").Select
Range("G4:AK20").Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("G4").Select
Sheets("11月").Select
ActiveWindow.SmallScroll
Range("G4:AK20").Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("G4").Select
Sheets("12月").Select
Range("G4:AK20").Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Sheets("公眾假期").Select
Range("A1").Select
作者:
PKKO
時間:
2014-11-14 06:27
回復
1#
hong912
試試看
Sub TEST()
For I = 1 To 12 '一月跑到12月
With Sheets(I & "月").Range("G4:AK20").Interior '用i當作月份跑回圈,後面範圍固定
.Pattern = xlNone '清除填滿的顏色
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Next
End Sub
複製代碼
作者:
hong912
時間:
2014-11-14 08:07
回復
2#
PKKO
謝謝指導, 感恩..
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)