Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1920|回复: 4

关于VBA error 13的求助

[复制链接]
发表于 2017-2-22 17:15 | 显示全部楼层 |阅读模式
这边有一个VBA语句,之前a=5 to 28,后来拓展了a=5 to 40, 一开始还是可以正常运行的,后来到达第30行的时候出现了ERROR 13的问题,红颜色的字体就是error 13 发生的地方,至今不知道原因。 源文件有点大,主要就是一个用来根据每个星期的销售情况来做整月预测的一个文件。数量级在五位数到六位数。  求大神帮忙解答!
For c = 2 To b
   For k = 1 To 16
   If Sheets(k).Cells(a, c) > 0 Then Sheets(k).Cells(a, c + 7) = Sheets(k).Cells(a, 7) / Sheets(k).Cells(a, c) - 1
   If Sheets(k).Cells(a, c) = 0 Then Sheets(k).Cells(a, c + 7) = "no value"
   Next k
  
   If Sheets(2).Cells(a, c + 14) > 0 Then Sheets(2).Cells(a, c + 21) = (Sheets(2).Cells(a, 21) / Sheets(2).Cells(a, c + 14)) - 1
   If Sheets(2).Cells(a, c + 14) = 0 Then Sheets(2).Cells(a, c + 21) = "no value"
   If Sheets(2).Cells(a, c + 28) > 0 Then Sheets(2).Cells(a, c + 35) = (Sheets(2).Cells(a, 35) / Sheets(2).Cells(a, c + 28)) - 1
   If Sheets(2).Cells(a, c + 28) = 0 Then Sheets(2).Cells(a, c + 35) = "no value"
   If Sheets(2).Cells(a, c + 42) > 0 Then Sheets(2).Cells(a, c + 49) = (Sheets(2).Cells(a, 49) / Sheets(2).Cells(a, c + 42)) - 1
   If Sheets(2).Cells(a, c + 42) = 0 Then Sheets(2).Cells(a, c + 49) = "no value"
   If Sheets(10).Cells(a, c + 14) > 0 Then Sheets(10).Cells(a, c + 21) = (Sheets(10).Cells(a, 21) / Sheets(10).Cells(a, c + 14)) - 1
   If Sheets(10).Cells(a, c + 14) = 0 Then Sheets(10).Cells(a, c + 21) = "no value"
   If Sheets(10).Cells(a, c + 28) > 0 Then Sheets(10).Cells(a, c + 35) = (Sheets(10).Cells(a, 35) / Sheets(10).Cells(a, c + 28)) - 1
   If Sheets(10).Cells(a, c + 28) = 0 Then Sheets(10).Cells(a, c + 35) = "no value"
   If Sheets(10).Cells(a, c + 42) > 0 Then Sheets(10).Cells(a, c + 49) = (Sheets(10).Cells(a, 49) / Sheets(10).Cells(a, c + 42)) - 1
   If Sheets(10).Cells(a, c + 42) = 0 Then Sheets(10).Cells(a, c + 49) = "no value"
  Next c
发表于 2017-2-22 17:20 | 显示全部楼层
回复

使用道具 举报

 楼主| 发表于 2017-2-22 17:25 | 显示全部楼层
liyizhe000 发表于 2017-2-22 17:20
有附件吗?上传附件看看

源文件太大了,传不上了,你要源vba嘛? 或者我给你截个图吧
回复

使用道具 举报

 楼主| 发表于 2017-2-22 17:28 | 显示全部楼层
liyizhe000 发表于 2017-2-22 17:20
有附件吗?上传附件看看

源文件的截图和VBA我已经附件了

Desktop.zip

39.89 KB, 下载次数: 1

源文件截图和vba

回复

使用道具 举报

发表于 2017-2-22 20:04 | 显示全部楼层
If Val(Sheets(k).Cells(a, c)) > 0 Then Sheets(k).Cells(a, c + 7) = Sheets(k).Cells(a, 7) / Sheets(k).Cells(a, c) - 1
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-4-29 06:47 , Processed in 0.269321 second(s), 13 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表