|
楼主 |
发表于 2018-3-5 17:23
|
显示全部楼层
写的有点乱,基本效果还是有的,用单元格黄色表达与日干的扶抑关系!
扶抑分析3.zip
(25.73 KB, 下载次数: 440)
'扶抑分析
wx = Array("水", "木", "火", "土", "金")
'日干ok
C = Cells(7, 4).Value
c1 = c1 + Val(Mid(C, 4, Len(C) - 1))
Cells(7, 4).Interior.ColorIndex = 6
For dzx = 1 To 5
If Mid(C, 2, 1) = wx(dzx - 1) Then Exit For
Next
If dzx = 1 Then dzz = 5 Else dzz = dzx - 1
'日支ok
For i = 1 To 3
cg0 = Cells(i + 11, 4).Value
If Mid(cg0, 2, 1) = wx(dzx - 1) Or Mid(cg0, 2, 1) = wx(dzz - 1) Then
c1 = c1 + Val(Mid(cg0, 4, Len(cg0) - 1))
Cells(i + 11, 4).Interior.ColorIndex = 6
Else
c2 = c2 + Val(Mid(cg0, 4, Len(cg0) - 1))
End If
Next
'时干ok
cg0 = Cells(7, 5).Value
For dzx2 = 1 To 5
If Mid(cg0, 2, 1) = wx(dzx2 - 1) Then Exit For
Next
If dzx2 = 1 Then dzz2 = 5 Else dzz2 = dzx2 - 1
If Mid(cg0, 2, 1) = wx(dzx - 1) Or Mid(cg0, 2, 1) = wx(dzz - 1) Then
c1 = c1 + Val(Mid(cg0, 4, Len(cg0) - 1))
Cells(7, 5).Interior.ColorIndex = 6
'时干生扶日干时,时支1
For i = 1 To 3
cg2 = Cells(i + 11, 5).Value
If Mid(cg2, 2, 1) = wx(dzx2 - 1) Or Mid(cg2, 2, 1) = wx(dzz2 - 1) Then
c1 = c1 + Val(Mid(cg2, 4, Len(cg2) - 1))
Cells(i + 11, 5).Interior.ColorIndex = 6
Else
c2 = c2 + Val(Mid(cg2, 4, Len(cg2) - 1))
End If
Next
Else
c2 = c2 + Val(Mid(cg0, 4, Len(cg0) - 1))
'时干不生扶日干时,时支2
For i = 1 To 3
cg2 = Cells(i + 11, 5).Value
If Mid(cg2, 2, 1) = wx(dzx2 - 1) Or Mid(cg2, 2, 1) = wx(dzz2 - 1) Then
c2 = c2 + Val(Mid(cg2, 4, Len(cg2) - 1))
Else
c1 = c1 + Val(Mid(cg2, 4, Len(cg2) - 1))
Cells(i + 11, 5).Interior.ColorIndex = 6
End If
Next
End If
'月干
cg0 = Cells(7, 3).Value
For dzx2 = 1 To 5
If Mid(cg0, 2, 1) = wx(dzx2 - 1) Then Exit For
Next
If dzx2 = 1 Then dzz2 = 5 Else dzz2 = dzx2 - 1
'年干
cg1 = Cells(7, 2).Value
For dzx3 = 1 To 5
If Mid(cg1, 2, 1) = wx(dzx3 - 1) Then Exit For
Next
If dzx3 = 1 Then dzz3 = 5 Else dzz3 = dzx3 - 1
If Mid(cg0, 2, 1) = wx(dzx - 1) Or Mid(cg0, 2, 1) = wx(dzz - 1) Then
c1 = c1 + Val(Mid(cg0, 4, Len(cg0) - 1))
Cells(7, 3).Interior.ColorIndex = 6
'月干生扶日干时,年干cg1
If Mid(cg1, 2, 1) = wx(dzx2 - 1) Or Mid(cg1, 2, 1) = wx(dzz2 - 1) Then
c1 = c1 + Val(Mid(cg1, 4, Len(cg2) - 1))
Cells(7, 2).Interior.ColorIndex = 6
'年干间接生扶日干时,年支1
For i = 1 To 3
cg3 = Cells(i + 11, 2).Value
If Mid(cg3, 2, 1) = wx(dzx3 - 1) Or Mid(cg3, 2, 1) = wx(dzz3 - 1) Then
c1 = c1 + Val(Mid(cg3, 4, Len(cg3) - 1))
Cells(i + 11, 2).Interior.ColorIndex = 6
Else
c2 = c2 + Val(Mid(cg3, 4, Len(cg3) - 1))
End If
Next
Else
c2 = c2 + Val(Mid(cg1, 4, Len(cg2) - 1))
'年干间接不生扶日干时,年支1
For i = 1 To 3
cg3 = Cells(i + 11, 2).Value
If Mid(cg3, 2, 1) = wx(dzx3 - 1) Or Mid(cg3, 2, 1) = wx(dzz3 - 1) Then
c2 = c2 + Val(Mid(cg3, 4, Len(cg3) - 1))
Else
c1 = c1 + Val(Mid(cg3, 4, Len(cg3) - 1))
Cells(i + 11, 2).Interior.ColorIndex = 6
End If
Next
End If
'月干生扶日干时,月支1
For i = 1 To 3
cg2 = Cells(i + 11, 3).Value
If Mid(cg2, 2, 1) = wx(dzx2 - 1) Or Mid(cg2, 2, 1) = wx(dzz2 - 1) Then
c1 = c1 + Val(Mid(cg2, 4, Len(cg2) - 1))
Cells(i + 11, 3).Interior.ColorIndex = 6
Else
c2 = c2 + Val(Mid(cg2, 4, Len(cg2) - 1))
End If
Next
Else
c2 = c2 + Val(Mid(cg0, 4, Len(cg0) - 1))
'月干不生扶日干时,年干cg1
If Mid(cg1, 2, 1) = wx(dzx2 - 1) Or Mid(cg1, 2, 1) = wx(dzz2 - 1) Then
c2 = c2 + Val(Mid(cg1, 4, Len(cg2) - 1))
'年干间接不生扶日干时,年支1
For i = 1 To 3
cg3 = Cells(i + 11, 2).Value
If Mid(cg3, 2, 1) = wx(dzx3 - 1) Or Mid(cg3, 2, 1) = wx(dzz3 - 1) Then
c2 = c2 + Val(Mid(cg3, 4, Len(cg3) - 1))
Else
c1 = c1 + Val(Mid(cg3, 4, Len(cg3) - 1))
Cells(i + 11, 2).Interior.ColorIndex = 6
End If
Next
Else
c1 = c1 + Val(Mid(cg1, 4, Len(cg2) - 1))
'年干间接生扶日干时,年支1
For i = 1 To 3
cg3 = Cells(i + 11, 2).Value
If Mid(cg3, 2, 1) = wx(dzx3 - 1) Or Mid(cg3, 2, 1) = wx(dzz3 - 1) Then
c1 = c1 + Val(Mid(cg3, 4, Len(cg3) - 1))
Cells(i + 11, 2).Interior.ColorIndex = 6
Else
c2 = c2 + Val(Mid(cg3, 4, Len(cg3) - 1))
End If
Next
End If
'月干不生扶日干时,月支2
For i = 1 To 3
cg2 = Cells(i + 11, 3).Value
If Mid(cg2, 2, 1) = wx(dzx2 - 1) Or Mid(cg2, 2, 1) = wx(dzz2 - 1) Then
c2 = c2 + Val(Mid(cg2, 4, Len(cg2) - 1))
Else
c1 = c1 + Val(Mid(cg2, 4, Len(cg2) - 1))
Cells(i + 11, 3).Interior.ColorIndex = 6
End If
Next
End If
Cells(4, 4).Value = c1
Cells(5, 4).Value = c2
|
|