現在我有一個宏PopulateYearlyValues
但在我看來,它採取的方式太長加快Excel宏?
Sub PopulateYearlyValues(ByVal Month As Range)
Dim c As Double
Dim s As Double
c = Application.WorksheetFunction.Match(UCase(Month.Value), ActiveSheet.Range("AA5:AX5"), 0)
s = (ActiveSheet.Range("AA5").Column - 1)
With ActiveSheet
Dim i As Integer
Dim j As Integer
For i = 7 To 44
.Range("G" & i).Value = 0
.Range("H" & i).Value = 0
For j = 1 To c
.Range("G" & i).Value = (.Range("G" & i).Value + .Cells(i, s).Offset(0, j))
.Range("H" & i).Value = (.Range("H" & i).Value + .Cells(i, s).Offset(0, (j + 1)))
j = j + 1
Next j
Next i
End With
End Sub
我有需要用的範圍AA7:AX44
的SUM
,但被填充的範圍G7:H44
..它只是每隔一列:
If Month.Value = "January"
G7 = SUM(AA7)
H7 = SUM(AB7)
...
G44 = SUM(AA44)
H44 = SUM(AB44)
End If
If Month.Value = "April"
G7 = SUM(AA7, AC7, AE7, AG7)
H7 = SUM(AB7, AD7, AF7, AH7)
...
G44 = SUM(AA44, AC44, AE44, AG44)
H44 = SUM(AB44, AD44, AF44, AH44)
End If
但是我的宏已經太長了..有沒有其他方法可以做到這一點?
你有關閉Application.ScreenUpdate這個功能呢? – Tommy 2010-06-17 12:02:05