EXCEL根据条件判断几个单元格的数值所代表的属性,if语句或者vba都可以,跪求大神帮忙!
EXCEL根据条件判断几个单元格的数值所代表的属性,条件如下:豹子就是A2、B2、C2三个单元格数字都相同。如:222、666、888...顺子就是A2、B2、C2三个单...
EXCEL根据条件判断几个单元格的数值所代表的属性,条件如下:豹子就是A2、B2、C2三个单元格数字都相同。如:222、666、888...顺子就是A2、B2、C2三个单元格数字都相连,不分顺序(数字9、0、1相连)。如:123、901、321、798...对子就是A2、B2、C2三个单元格数字任意两位数字相同(不包括豹子)。如:001,288、696...半顺就是A2、B2、C2三个单元格数字任意两位数字相连,不分顺序(不包括顺子、对子)。如:125、540、390、160...杂六就是A2、B2、C2三个单元格数字不包括豹子、对子、顺子、半顺的所有号码。牛牛就是五个号码里三个号码的总和为10的倍数,另外两个号码的总和也为10的倍数,如: 1,1,7,3,8(1+1+8=10,3+7=10就是牛牛)牛1~牛9就是五个号码里三个号码的总和为10的倍数,另外两个号码的总和除以10余几为牛几,如: 1 ,2 ,7 ,4 ,5为牛9。(1+2+7=10,4+5=9就是牛9)5,8,5,1,7为牛六(8+7+5=20,5+1=6,就是牛六。)无牛就是任意三个号码的总和都不为10的倍数,如为:1,2,6,9,8为无牛。
望大神支招,纯学术研究!只是想知道用EXCEL如何去实现这种功能。 展开
望大神支招,纯学术研究!只是想知道用EXCEL如何去实现这种功能。 展开
3个回答
2015-03-09
展开全部
=IF(LARGE(A2:C2,1)=SMALL(A2:C2,1),"豹子",IF(OR(LARGE(A2:C2,1)=LARGE(A2:C2,2),SMALL(A2:C2,1)=SMALL(A2:C2,2)),"对子",IF(OR(LARGE(A2:C2,1)-AVERAGE(A2:C2)=1,AND(LARGE(A2:C2,1)=9,LARGE(A2:C2,2)=1,SMALL(A2:C2,1)=0)),"顺子",IF(OR(LARGE(A2:C2,1)-LARGE(A2:C2,2)=1,SMALL(A2:C2,2)-SMALL(A2:C2,1)=1),"半顺","杂六"))))
追问
这个很好,牛牛那个你知道怎么弄吗?
追答
比较复杂,暂时想不到
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用公式几乎不大可能实现,就算用VBA也很复杂的,你在买排列5吗?
如下模块实现前三的统计,跑跑看,
Sub jisuan()
For i = 2 To Application.CountA(Range("a:a"))
a = Cells(i, 1)
b = Cells(i, 2)
c = Cells(i, 3)
d = Cells(i, 4)
e = Cells(i, 5)
c3 = a & b & c
If a = b And b = c Then
Cells(i, 6) = "豹子"
ElseIf Not IsError(Application.Find("0", c3)) And Not IsError(Application.Find("1", c3)) And Not IsError(Application.Find("9", c3)) Then
Cells(i, 6) = "顺子"
ElseIf Not IsError(Application.Find("0", c3)) And Not IsError(Application.Find("9", c3)) And Not IsError(Application.Find("8", c3)) Then
Cells(i, 6) = "顺子"
ElseIf (a = b + 1 And b = c + 1) Or (a = c + 1 And c = b + 1) Or (b = c + 1 And c = a + 1) Or (b = a + 1 And a = c + 1) Or (c = a + 1 And a = b + 1) Or (c = b + 1 And b = a + 1) Then
Cells(i, 6) = "顺子"
ElseIf a = b Or a = c Or b = c Then
Cells(i, 6) = "对子"
ElseIf a = b + 1 Or a = c + 1 Or b = a + 1 Or b = c + 1 Or c = a + 1 Or c = b + 1 Or (Not IsError(Application.Find("0", c3)) And Not IsError(Application.Find("1", c3))) Or (Not IsError(Application.Find("0", c3)) And Not IsError(Application.Find("9", c3))) Then
Cells(i, 6) = "半顺"
Else
Cells(i, 6) = "杂六"
End If
Next
End Sub
如下模块实现前三的统计,跑跑看,
Sub jisuan()
For i = 2 To Application.CountA(Range("a:a"))
a = Cells(i, 1)
b = Cells(i, 2)
c = Cells(i, 3)
d = Cells(i, 4)
e = Cells(i, 5)
c3 = a & b & c
If a = b And b = c Then
Cells(i, 6) = "豹子"
ElseIf Not IsError(Application.Find("0", c3)) And Not IsError(Application.Find("1", c3)) And Not IsError(Application.Find("9", c3)) Then
Cells(i, 6) = "顺子"
ElseIf Not IsError(Application.Find("0", c3)) And Not IsError(Application.Find("9", c3)) And Not IsError(Application.Find("8", c3)) Then
Cells(i, 6) = "顺子"
ElseIf (a = b + 1 And b = c + 1) Or (a = c + 1 And c = b + 1) Or (b = c + 1 And c = a + 1) Or (b = a + 1 And a = c + 1) Or (c = a + 1 And a = b + 1) Or (c = b + 1 And b = a + 1) Then
Cells(i, 6) = "顺子"
ElseIf a = b Or a = c Or b = c Then
Cells(i, 6) = "对子"
ElseIf a = b + 1 Or a = c + 1 Or b = a + 1 Or b = c + 1 Or c = a + 1 Or c = b + 1 Or (Not IsError(Application.Find("0", c3)) And Not IsError(Application.Find("1", c3))) Or (Not IsError(Application.Find("0", c3)) And Not IsError(Application.Find("9", c3))) Then
Cells(i, 6) = "半顺"
Else
Cells(i, 6) = "杂六"
End If
Next
End Sub
更多追问追答
追问
是的,只是研究一下概率。。还没买。。牛牛那个你知道怎么弄吗?
追答
Sub 算牛牛()
For n = 2 To Application.CountA(Range("a:a"))
For i = 1 To 5
For j = 1 To 5
For k = 1 To 5
sumx = 0
sumy = 0
If i j And i k And j k Then
sumx = Cells(n, i) + Cells(n, j) + Cells(n, k)
If sumx / 10 = Int(sumx / 10) Then
c3 = i & j & k
For o = 1 To 5
If IsError(Application.Find(o, c3)) Then sumy = sumy + Cells(n, o)
Next
If sumy > 10 Then sumy = sumy - 10
If sumy = 10 Then Cells(n, 7) = "牛牛" Else Cells(n, 7) = "牛" & sumy
End If
End If
Next
Next
Next
If Cells(n, 7) = "" Then Cells(n, 7) = "无牛"
Next
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你这肯定不是纯学术研究。
自己研究if语句吧,多个if嵌套。
自己研究if语句吧,多个if嵌套。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询