Excel精英培训网

 找回密码
 注册

countif

已有 509 次阅读2016-5-13 14:46

Sub celia()
For j = 2 To 4
For i = 2 To 94
If Sheet1.Cells(i, 1) = Sheet2.Cells(j, 1) Then
myCount = myCount + 1
End If
Next
Sheet2.Cells(j, 2) = myCount
Next
End Sub
Sub natenie()
For i = 2 To 94
myCount = Application.WorksheetFunction.CountIf(Sheet1.Rows(i), 0) + Application.WorksheetFunction.CountIf(Sheet1.Rows(i), "外出")
If myCount = 1 Or myCount = 2 Or myCount = 3 Or myCount = 4 Then Sheet1.Cells(i, 8) = 1
Next
End Sub
Sub four()
For j = 2 To 4
myCount = 0
For i = 2 To 94
If Sheet1.Cells(i, 1) = Sheet2.Cells(j, 1) And Sheet1.Cells(i, 8) = 1 Then
myCount = myCount + Application.WorksheetFunction.CountIf(Sheet1.Rows(i), 1): Sheet2.Cells(j, 3) = myCount
End If
Next
Next
End Sub

评论 (0 个评论)

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

GMT+8, 2024-6-29 08:11 , Processed in 0.167283 second(s), 5 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

返回顶部