Excel精英培训网

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

[已解决]帮忙看看程序

[复制链接]
发表于 2014-6-24 14:20 | 显示全部楼层 |阅读模式
帮忙看看
我执行B列,C列,H列,就出现类型不匹配,执行其他列能运行过去

Private Sub Worksheet_Change(ByVal Target As Range)
'tm = Timer
r = Target.Row '当前单元格行
c = Target.Column '当前单元格列
    If c = 2 And r > 3 Then
        Cells(r, 1) = r - 3
    End If
    '在A列自动生成序号

    If c = 4 Then
        Cells(r, c + 2) = Cells(r, c) - Cells(r, c + 1)
    End If
      '在第四列中输入令数,开始计算(未执行计划数)

    If c Mod 2 = 0 And c / 2 > 5 Then
        Cells(r, 7) = Application.SumIf(Range(Cells(3, 11), Cells(3, 72)), "完成", Range(Cells(r, 11), Cells(r, 72)))
        If Cells(r, 7) + Cells(r, 5) > Cells(r, 4) Then
           MsgBox "你的完成数超出计划数,请核查"
           Cells(r, c) = ""

           Cells(r, 1).Resize(1, 10).Interior.ColorIndex = 0

           If Cells(r, 7) + Cells(r, 5) = Cells(r, 4) Then
              Cells(r, 1).Resize(1, 10).Interior.Color = vbRed
           End If
         ElseIf Cells(r, 7) + Cells(r, 5) = Cells(r, 4) Then
              Cells(r, 1).Resize(1, 10).Interior.Color = vbRed
         Else

           Cells(r, 1).Resize(1, 10).Interior.ColorIndex = 0
        End If
    End If

    If r > 3 And c Mod 2 = 1 And c > 10 And Application.SumIf(Range(Cells(3, 11), Cells(3, c)), "完成", Range(Cells(r, 11), Cells(r, c))) + Cells(r, c) > Cells(r, 6) Then
        MsgBox "此次计划数超出未执行计划数,请核查"
        Cells(r, c) = ""
    End If

'MsgBox "运行时间:" & Timer - tm
End Sub
最佳答案
2014-6-24 14:52
有错误三  Cells(r, c))) + Cells(r, c) > Cells(r, 6) 运行时,这是文字,不是数错,则要出错

201401计划甘特图.rar

21.73 KB, 下载次数: 2

excel精英培训的微信平台,每天都会发送excel学习教程和资料。扫一扫明天就可以收到新教程
发表于 2014-6-24 14:52 | 显示全部楼层    本楼为最佳答案   
有错误三  Cells(r, c))) + Cells(r, c) > Cells(r, 6) 运行时,这是文字,不是数错,则要出错
回复

使用道具 举报

 楼主| 发表于 2014-6-24 15:02 | 显示全部楼层
知道了,我写成两层的IF语句,问题解决了,
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-5-16 20:48 , Processed in 0.283965 second(s), 12 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

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