全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 Excel
1303 4
2013-07-31
下面是Excel VBA 一段程序,目的是要改变一些变量 withdraw, death_a_rate, comm_rate, invest_a_rate, fee, ex_rate这六个然后把改变后想要的数据结果 Worksheets("利润测试").Cells(10, l(这都是L)).Value 这里的 生成一张9行14列的表格。

但是到黄色那句就显示下标越界了!请问问题在哪怎么改啊!我刚学VBA。。
对能解决的感激涕零!

代码如下:

Dim age, f, c, i, e, w, d, h, l As Integer
Dim withdraw, death_a_rate, comm_rate, invest_a_rate, fee, ex_rate, result, database As Variant

withdraw = Array(1.5, 1.25, 0.75)
death_a_rate = Array(1.1, 0.9, 0.8)
comm_rate = Array(1.1, 1.05, 0.95)
invest_a_rate = Array(0.055, 0.045, 0.04)
fee = Array(1.5, 1.25, 0.75)
ex_rate = Array(1.2, 1.1, 0.9)
Range("scer").ClearContents
result = Range("scer").Value

For l(这是L) = 1 To 14
h = 2
For i = 0 To 2
Range("invest_rate_adjust").Value = invest_a_rate(i)
h = h + i
result(h, l) = Worksheets("利润测试").Cells(10, l).Value
Range("invest_rate_adjust").Value = 0
Next i
h = h + 1

For w = 0 To 2
Range("withdraw_adjust").Value = withdraw(w)
h = h + w
result(h, l) = Worksheets("利润测试").Cells(10, l).Value
Range("withdraw_adjust").Value = 1
Next w
h = h + 1

For d = 0 To 2
Range("death_rate_adjust").Value = death_a_rate(d)
h = h + d
result(h, l) = Worksheets("利润测试").Cells(10, l).Value
Range("death_rate_adjust").Value = 1
Next d
h = h + 1

For e = 0 To 2
Range("ex_adjust").Value = ex_rate(e)
h = h + e
result(h, l) = Worksheets("利润测试").Cells(10, l).Value
Range("ex_adjust").Value = 1
Next e
h = h + 1

For f = 0 To 2
Range("ave_prem_adjust").Value = fee(f)
h = h + f
result(h, l) = Worksheets("利润测试").Cells(10, l).Value
Range("ave_prem_adjust").Value = 1
Next f
h = h + 1

For c = 0 To 2
Range("comm_adjust").Value = comm_rate(c)
h = h + c
result(h, l) = Worksheets("利润测试").Cells(10, l).Value
Range("ave_prem_adjust").Value = 1
Next c
h = h + 1
Next l
Range("scer").Value = result


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2013-7-31 17:01:50
自己顶一下,有看见会的帮帮忙哦!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-7-31 17:05:10
上传附件吧,这看的累死了
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-7-31 17:17:38
fftangwen 发表于 2013-7-31 17:05
上传附件吧,这看的累死了
那个EXCEL不允许传的额。我也没有办法嘛。。。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2013-7-31 17:22:27
fftangwen 发表于 2013-7-31 17:05
上传附件吧,这看的累死了
那个EXCEL不允许传的额。我也没有办法嘛。。。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群