电脑统计VBA
Sub 按钮2_Click() Dim n0 As Integer, n1 As Integer, n2 As Integer, n3 As Integer, n4 As Integer, n5 As Integer, n6 As Integer n1 = WorksheetFunction.CountIf(Range("J:J"), "国内营销中心") n2 = WorksheetFunction.CountIf(Range("J:J"), "技术中心") n3 = WorksheetFunction.CountIf(Range("J:J"), "生产总监办公室") n4 = WorksheetFunction.CountIf(Range("J:J"), "包装车间") n5 = WorksheetFunction.CountIf(Range("J:J"), "半成品车间") n6 = WorksheetFunction.CountIf(Range("J:J"), "生产设备保障部") n7 = WorksheetFunction.CountIf(Range("J:J"), "物流部") n8 = WorksheetFunction.CountIf(Range("J:J"), "办公室") n9 = WorksheetFunction.CountIf(Range("J:J"), "质量保证部") n10 = WorksheetFunction.CountIf(Range("J:J"), "检验中心") n11 = WorksheetFunction.CountIf(Range("J:J"), "财务部") n12 = WorksheetFunction.CountIf(Range("J:J"), "市场部") n13 = WorksheetFunction.CountIf(Range("J:J"), "采购部") n14 = WorksheetFunction.CountIf(Range("J:J"), "人力企管部") n15 = WorksheetFunction.CountIf(Range("J:J"), "工程信息中心") n16 = WorksheetFunction.CountIf(Range("J:J"), "高管") n17 = WorksheetFunction.CountIf(Range("J:J"), "技术中心") n18 = WorksheetFunction.CountIf(Range("J:J"), "技术中心") MsgBox "国内营销中心电脑的台数为:" & n1 & Chr(13) & "技术中心电脑的台数为:" & n2 End Sub
Sub 按钮2_Click() Dim n0 As Integer, n1 As Integer, n2 As Integer, n3 As Integer, n4 As Integer, n5 As Integer, n6 As Integer n1 = WorksheetFunction.CountIf(Range("J:J"), "国内营销中心") n2 = WorksheetFunction.CountIf(Range("J:J"), "技术中心") n3 = WorksheetFunction.CountIf(Range("J:J"), "生产总监办公室") n4 = WorksheetFunction.CountIf(Range("J:J"), "包装车间") n5 = WorksheetFunction.CountIf(Range("J:J"), "半成品车间") n6 = WorksheetFunction.CountIf(Range("J:J"), "生产设备保障部") n7 = WorksheetFunction.CountIf(Range("J:J"), "物流部") n8 = WorksheetFunction.CountIf(Range("J:J"), "办公室") n9 = WorksheetFunction.CountIf(Range("J:J"), "质量保证部") n10 = WorksheetFunction.CountIf(Range("J:J"), "检验中心") n11 = WorksheetFunction.CountIf(Range("J:J"), "财务部") n12 = WorksheetFunction.CountIf(Range("J:J"), "市场部") n13 = WorksheetFunction.CountIf(Range("J:J"), "采购部") n14 = WorksheetFunction.CountIf(Range("J:J"), "人力企管部") n15 = WorksheetFunction.CountIf(Range("J:J"), "工程信息中心") n16 = WorksheetFunction.CountIf(Range("J:J"), "高管") n17 = WorksheetFunction.CountIf(Range("J:J"), "技术中心") n18 = WorksheetFunction.CountIf(Range("J:J"), "技术中心") Range("E1").Value = "国内营销中心" & n1 & "台 " & "技术中心" & n2 & "台 " & "生产总监办公室" & n3 & "台 " & "生产设备保障部" & n6 & "台 " & "包装车间" & n4 & "台 " & "半成品车间" & n5 & "台 " & "物流部" & n7 & "台 " & "办公室" & n8 & "台 " & "质量保障部" & n9 & "台 " & "检验中心" & n10 & "台 " & "财务部" & n11 & "台 " & "市场部" & n12 & "台 " & "采购部" & n13 & "台 " & "人力企管部" & n14 & "台 " & "工程信息中心" & n15 & "台 " & "高管" & n16 & "台 " 'MsgBox "国内营销中心:" & n1 & "技术中心:" & n2 & "生产总监办公室:" & n3 & "包装车间:" & n4 & Chr(13) & "半成品车间:" & n5 & "生产设备保障部:" & n6 & "物流部:" & n7 & Chr(13) & "办公室:" & n8 & "质量保障部:" & n9 & "检验中心:" & n10 End Sub Sub 按钮1_Click() Dim n0 As Integer, n1 As Integer, n2 As Integer, n3 As Integer, n4 As Integer, n5 As Integer, n6 As Integer n1 = WorksheetFunction.CountIf(Range("J:J"), "国内营销中心") n2 = WorksheetFunction.CountIf(Range("J:J"), "技术中心") n3 = WorksheetFunction.CountIf(Range("J:J"), "生产总监办公室") n4 = WorksheetFunction.CountIf(Range("J:J"), "包装车间") n5 = WorksheetFunction.CountIf(Range("J:J"), "半成品车间") n6 = WorksheetFunction.CountIf(Range("J:J"), "生产设备保障部") n7 = WorksheetFunction.CountIf(Range("J:J"), "物流部") n8 = WorksheetFunction.CountIf(Range("J:J"), "办公室") n9 = WorksheetFunction.CountIf(Range("J:J"), "质量保证部") n10 = WorksheetFunction.CountIf(Range("J:J"), "检验中心") n11 = WorksheetFunction.CountIf(Range("J:J"), "财务部") n12 = WorksheetFunction.CountIf(Range("J:J"), "市场部") n13 = WorksheetFunction.CountIf(Range("J:J"), "采购部") n14 = WorksheetFunction.CountIf(Range("J:J"), "人力企管部") n15 = WorksheetFunction.CountIf(Range("J:J"), "工程信息中心") n16 = WorksheetFunction.CountIf(Range("J:J"), "高管") Range("C1").Value = "PC总计" & n1 + n2 + n3 + n4 + n5 + n6 + n7 + n8 + n9 + n10 + n11 + n12 + n13 + n14 + n15 + n16 & "台 " End Sub Sub 按钮4_Click() Range("C1").Value = "" Range("E1").Value = "" End Sub