急~~~~1004 应用程序定义或对象定义错误。。。。。
本帖最后由 bcrun 于 2013-04-29 20:28:22 编辑 在其它机子运行没有问题,然后在win8系统打开这个excel的时候,即便不是运行随便点击一个单元格都出现提示说: 1004 应用程序定义或对象定义错误。。。。。这是什么回事啊。我按调试,就弹到一下这段代码:
Sub Caculate()b
Application.CommandBars("Control Toolbox").Visible = True
ActiveSheet.OLEObjects.Add(ClassType:="Forms.CommandButton.1", Link:=False _
, DisplayAsIcon:=False, Left:=1229.25, Top:=57, Width:=267, Height:= _
72).Select
End Su
Private Sub CommandButton1_Click()excel?VBA
Dim j As Integer
Dim i As Integer
Dim mycountAL As Integer, mycountOL As Integer
Dim mycountSL As Integer, mycountCL As Integer
Dim Training As Integer, mycountHL As Integer
Dim mycountAL1 As Integer, mycountOL1 As Integer
Dim mycountSL1 As Integer, mycountCL1 As Integer
Dim Training1 As Integer, mycountHL1 As Integer
Dim TTL As Integer, TotalOT As Integer
Dim TTL1 As Integer
Dim RegO As Integer, CSPO As Integer
Dim RegO1 As Integer, CSPO1 As Integer
Dim TWH As Integer, PH As Integer
Dim WD As Integer
Dim Target As range
Dim mycountRegO As Integer, mycountCSPO As Integer
For i = 5 To range("A65536").End(xlUp).Row
For j = 5 To range("A65536").End(xlUp).Row
If range("AO7").Value <= range("AQ7").Value Then
If range("AO7").Value = range("A" & i).Value Then
If range("AQ7").Value = range("A" & j).Value Then
ActiveSheet.range("C" & i, "AJ" & j).Select
mycountAL = Application.WorksheetFunction.CountIf(range("C" & i, "AF" & j), "AL")
mycountOL = Application.WorksheetFunction.CountIf(range("C" & i, "AF" & j), "OL")
mycountSL = Application.WorksheetFunction.CountIf(range("C" & i, "AF" & j), "SL")
mycountCL = Application.WorksheetFunction.CountIf(range("C" & i, "AF" & j), "CL")
Training = Application.WorksheetFunction.CountIf(range("C" & i, "AF" & j), "TR")
mycountHL = Application.WorksheetFunction.CountIf(range("C" & i, "AF" & j), "HL")
RegO = Application.WorksheetFunction.Sum(range("C" & i, "AD" & j))
RegO1 = Application.WorksheetFunction.Sum(range("AG" & i, "AJ" & j))
CSPO = Application.WorksheetFunction.Sum(range("AE" & i, "AF" & j))
mycountAL1 = Application.WorksheetFunction.CountIf(range("C" & i, "AJ" & j), "AL")
mycountOL1 = Application.WorksheetFunction.CountIf(range("C" & i, "AJ" & j), "OL")
mycountSL1 = Application.WorksheetFunction.CountIf(range("C" & i, "AJ" & j), "SL")
mycountCL1 = Application.WorksheetFunction.CountIf(range("C" & i, "AJ" & j), "CL")
Training1 = Application.WorksheetFunction.CountIf(range("C" & i, "AJ" & j), "TR")
mycountHL1 = Application.WorksheetFunction.CountIf(range("C" & i, "AJ" & j), "HL")
TTL = range("AN7").Value = mycountAL + mycountOL + mycountCL + mycountHL + mycountSL + Training
range("AL7").Value = mycountAL1
range("AL10").Value = mycountOL1
range("AL11").Value = mycountSL1
range("AL9").Value = mycountCL1
range("AL12").Value = Training1
range("AL8").Value = mycountHL1
range("AM7").Value = mycountAL1 + mycountOL1 + mycountCL1 + mycountHL1 + mycountSL1 + Training1
range("AL15").Value = RegO + RegO1
range("AL16").Value = CSPO
range("AM15").Value = range("AM15").Value + CSPO
range("AK25").Value = range("AK19").Value * 8 * 30 'all people in work
range("AM19").Value = range("AK25").Value - TTL
range("AO17").Value = range("AM19") + range("AL16").Value + RegO
End If
End If
Else
MsgBox "your input date is wrong,please reinput it"
Exit Sub
End If
Next
Next
End Sub