標題:
[發問]
請問這式子怎麼精簡?(解決了,感恩!)
[打印本頁]
作者:
olisun
時間:
2010-8-10 00:26
標題:
請問這式子怎麼精簡?(解決了,感恩!)
本帖最後由 olisun 於 2010-8-10 01:32 編輯
請問這式子怎麼精簡?
Sheets(5).Range("j4").Value = Application.Sum(Application.Index(Arr1, 0, 3))
Sheets(5).Range("j5").Value = Application.Sum(Application.Index(Arr1, 0, 4))
Sheets(5).Range("j6").Value = Application.Sum(Application.Index(Arr1, 0, 5))
Sheets(5).Range("j7").Value = Application.Sum(Application.Index(Arr1, 0, 6))
Sheets(5).Range("j8").Value = Application.Sum(Application.Index(Arr1, 0, 7))
Sheets(5).Range("j9").Value = Application.Sum(Application.Index(Arr1, 0, 8))
Sheets(5).Range("j10").Value = Application.Sum(Application.Index(Arr1, 0, 9))
Sheets(5).Range("j11").Value = Application.Sum(Application.Index(Arr1, 0, 10))
Sheets(5).Range("j12").Value = Application.Sum(Application.Index(Arr1, 0, 11))
Sheets(5).Range("j13").Value = Application.Sum(Application.Index(Arr1, 0, 12))
Sheets(5).Range("j14").Value = Application.Sum(Application.Index(Arr1, 0, 13))
Sheets(5).Range("j15").Value = Application.Sum(Application.Index(Arr1, 0, 14))
Sheets(5).Range("j16").Value = Application.Sum(Application.Index(Arr1, 0, 15))
Sheets(5).Range("j17").Value = Application.Sum(Application.Index(Arr1, 0, 16))
Sheets(5).Range("j18").Value = Application.Sum(Application.Index(Arr1, 0, 17))
Sheets(5).Range("j19").Value = Application.Sum(Application.Index(Arr1, 0, 18))
Sheets(5).Range("j20").Value = Application.Sum(Application.Index(Arr1, 0, 19))
Sheets(5).Range("j21").Value = Application.Sum(Application.Index(Arr1, 0, 20))
Sheets(5).Range("j22").Value = Application.Sum(Application.Index(Arr1, 0, 21))
Sheets(5).Range("j23").Value = Application.Sum(Application.Index(Arr1, 0, 22))
Sheets(5).Range("j24").Value = Application.Sum(Application.Index(Arr1, 0, 23))
Sheets(5).Range("j25").Value = Application.Sum(Application.Index(Arr1, 0, 24))
Sheets(5).Range("j26").Value = Application.Sum(Application.Index(Arr1, 0, 25))
Sheets(5).Range("j27").Value = Application.Sum(Application.Index(Arr1, 0, 26))
Sheets(5).Range("j28").Value = Application.Sum(Application.Index(Arr1, 0, 27))
Sheets(5).Range("j29").Value = Application.Sum(Application.Index(Arr1, 0, 28))
Sheets(5).Range("j30").Value = Application.Sum(Application.Index(Arr1, 0, 29))
Sheets(5).Range("j31").Value = Application.Sum(Application.Index(Arr1, 0, 30))
Sheets(5).Range("j32").Value = Application.Sum(Application.Index(Arr1, 0, 31))
Sheets(5).Range("j33").Value = Application.Sum(Application.Index(Arr1, 0, 32))
Sheets(5).Range("j34").Value = Application.Sum(Application.Index(Arr1, 0, 33))
Sheets(5).Range("j35").Value = Application.Sum(Application.Index(Arr1, 0, 34))
Sheets(5).Range("j36").Value = Application.Sum(Application.Index(Arr1, 0, 35))
Sheets(5).Range("j37").Value = Application.Sum(Application.Index(Arr1, 0, 36))
作者:
luhpro
時間:
2010-8-10 00:44
Dim iI%
For iI = 3 To 36
Sheets(5).Cells(iI + 1, 10).Value = Application.Sum(Application.Index(Arr1, 0, iI))
Next iI
當 Range() 的元素需要做計算時,
可以善用 Cells() 來取代.
作者:
olisun
時間:
2010-8-10 00:56
謝謝,那這個式子呢
.Range("H4").Value = .Range("F4").Value + .Range("G4").Value '初看未購原因累計
.Range("H5").Value = .Range("F5").Value + .Range("G5").Value
.Range("H6").Value = .Range("F6").Value + .Range("G6").Value
.Range("H7").Value = .Range("F7").Value + .Range("G7").Value
.Range("H8").Value = .Range("F8").Value + .Range("G8").Value
.Range("H9").Value = .Range("F9").Value + .Range("G9").Value
.Range("H10").Value = .Range("F10").Value + .Range("G10").Value
.Range("H11").Value = .Range("F11").Value + .Range("G11").Value
.Range("H12").Value = .Range("F12").Value + .Range("G12").Value
.Range("H13").Value = .Range("F13").Value + .Range("G13").Value
.Range("H14").Value = .Range("F14").Value + .Range("G14").Value
.Range("H15").Value = .Range("F15").Value + .Range("G15").Value
.Range("H16").Value = .Range("F16").Value + .Range("G16").Value
.Range("H17").Value = .Range("F17").Value + .Range("G17").Value
.Range("H18").Value = .Range("F18").Value + .Range("G18").Value
.Range("H19").Value = .Range("F19").Value + .Range("G19").Value
.Range("H20").Value = .Range("F20").Value + .Range("G20").Value
.Range("H21").Value = .Range("F21").Value + .Range("G21").Value
.Range("H22").Value = .Range("F22").Value + .Range("G22").Value
.Range("H23").Value = .Range("F23").Value + .Range("G23").Value
.Range("H24").Value = .Range("F24").Value + .Range("G24").Value
.Range("H25").Value = .Range("F25").Value + .Range("G25").Value
.Range("H26").Value = .Range("F26").Value + .Range("G26").Value
.Range("H27").Value = .Range("F27").Value + .Range("G27").Value
.Range("H28").Value = .Range("F28").Value + .Range("G28").Value
.Range("H29").Value = .Range("F29").Value + .Range("G29").Value
.Range("H30").Value = .Range("F30").Value + .Range("G30").Value
.Range("H31").Value = .Range("F31").Value + .Range("G31").Value
.Range("H32").Value = .Range("F32").Value + .Range("G32").Value
.Range("H33").Value = .Range("F33").Value + .Range("G33").Value
.Range("H34").Value = .Range("F34").Value + .Range("G34").Value
.Range("H35").Value = .Range("F35").Value + .Range("G35").Value
.Range("H36").Value = .Range("F36").Value + .Range("G36").Value
.Range("H37").Value = .Range("F37").Value + .Range("G37").Value
.Range("H38").Value = .Range("F38").Value + .Range("G38").Value
作者:
kimbal
時間:
2010-8-10 01:00
for i = 4 to 38
.Range("H"&i).Value = .Range("F"&i).Value + .Range("G"&i).Value
next
複製代碼
作者:
olisun
時間:
2010-8-10 01:31
謝謝,把這搞懂那就省事多了,感恩!
作者:
jntseng
時間:
2010-8-14 01:13
回復
2#
luhpro
可以請問Application.Index() 代表什麼意思嗎? 目的為何? 有什麼作用?
作者:
Hsieh
時間:
2010-8-16 15:58
回復
6#
jntseng
引用工作表函數index
歡迎光臨 麻辣家族討論版版 (http://forum.twbts.com/)