>即時新聞-熱門

2009年2月28日星期六

excel vba - array 陣列

Sub 資料搬移()

Dim myx, myi



arydataSec1 = Array("g5", "k5", "k6", "c6", "c5", "g7") ' 開課基本資料
arydataSec2 = Array("b12", "b13", "b14", "b15", "b16") ' 滿意度1
arydataSec3 = Array("c12", "c13", "c14", "c15", "c16") ' 滿意度2
arydataSec4 = Array("d12", "d13", "d14", "d15", "d16") ' 滿意度3
arydataSec5 = Array("e12", "e13", "e14", "e15", "e16") ' 滿意度4
arydataSec6 = Array("f12", "f13", "f14", "f15", "f16") ' 滿意度5
arydataSec7 = Array("g12", "g13", "g14", "g15", "g16") ' 滿意度6
arydataSec8 = Array("h12", "h13", "h14", "h15", "h16") ' 滿意度7
arydataSec9 = Array("i12", "i13", "i14", "i15", "i16") ' 滿意度8
arydataSeca = Array("k12", "k13", "k14", "k15", "k16") ' 滿意度9
arydataSecb = Array("b21", "b22", "b23", "b24", "b25", "b26", "b27", "b28", "b29", "b30", "b31", "b32", "b33", "b34", "b35", "b36", "b37", "b38", "b39", "b40", "b41", "b42", "b43", "b44", "b45", "b46", "b47", "b48", "b49", "b50") ' 居住統計
arydataSecc = Array("f21", "f22", "f23") ' 性別
arydataSecd = Array("f25", "f26", "f27", "f28", "f29", "f30", "f31", "f32", "f33", "f34", "f35", "f36", "f37", "f38", "f39") ' 出生統計
arydataSece = Array("f41", "f42", "f43", "f44", "f45", "f46") ' 族群統計
arydataSecf = Array("f48", "f49", "f50") ' 成績統計
arydataSecg = Array("k21", "k22", "k23", "k24", "k25", "k26", "k27", "k28", "k29") ' 學歷統計
arydataSech = Array("k33", "k34", "k35", "k36", "k37", "k38", "k39", "k40", "k41", "k42") ' 職業統計
arydataSeci = Array("k45", "k46", "k47", "k48", "k49", "k50") ' 課程統計



For myi = 0 To 5
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSec1(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 1).Value = myx
Next myi

For myi = 0 To 4
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSec2(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 7).Value = myx
Next myi

For myi = 0 To 4
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSec3(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 12).Value = myx
Next myi


For myi = 0 To 4
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSec4(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 17).Value = myx
Next myi


For myi = 0 To 4
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSec5(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 22).Value = myx
Next myi

For myi = 0 To 4
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSec6(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 27).Value = myx
Next myi


For myi = 0 To 4
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSec7(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 32).Value = myx
Next myi


For myi = 0 To 4
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSec8(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 37).Value = myx
Next myi

For myi = 0 To 4
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSec9(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 42).Value = myx
Next myi


For myi = 0 To 4
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSeca(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 47).Value = myx
Next myi

For myi = 0 To 29
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSecb(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 52).Value = myx
Next myi

For myi = 0 To 2
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSecc(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 82).Value = myx
Next myi


For myi = 0 To 14
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSecd(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 85).Value = myx
Next myi


For myi = 0 To 5
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSece(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 100).Value = myx
Next myi


For myi = 0 To 2
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSecf(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 106).Value = myx
Next myi


For myi = 0 To 8
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSecg(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 109).Value = myx
Next myi

For myi = 0 To 9
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSech(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 118).Value = myx
Next myi


For myi = 0 To 5
Windows("數位落差結案檔.xls").Activate
myx = Sheets("滿意度調查統計表").Range(arydataSeci(myi)).Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, myi + 128).Value = myx
Next myi


Windows("數位落差結案檔.xls").Activate
myx = Sheets("B結訓學員名冊").Range("d56").Value
Windows("問卷統計.xls").Activate
ActiveCell.Offset(0, 133).Value = myx


ActiveWorkbook.Save
ActiveWindow.Close
End Sub

0 评论:

 
妹咕數位學園歡迎網友們來信指教 妹咕信箱