|
楼主 |
发表于 2018-11-9 21:15
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
函数调整如下!
Function sizhu(birth, Optional gs As Integer = 0) As String
Dim LSJZ
If Year(birth) > 7000 Then Exit Function
If Len(birth) = 0 Then Exit Function
tt$ = "甲子 乙丑 丙寅 丁卯 戊辰 已巳 庚午 辛未 壬申 癸酉 甲戌 乙亥 " _
& "丙子 丁丑 戊寅 已卯 庚辰 辛巳 壬午 癸未 甲申 乙酉 丙戌 丁亥 " _
& "戊子 已丑 庚寅 辛卯 壬辰 癸巳 甲午 乙未 丙申 丁酉 戊戌 已亥 " _
& "庚子 辛丑 壬寅 癸卯 甲辰 乙巳 丙午 丁未 戊申 已酉 庚戌 辛亥 " _
& "壬子 癸丑 甲寅 乙卯 丙辰 丁巳 戊午 已未 庚申 辛酉 壬戌 癸亥 "
SX = "鼠牛虎兔龙蛇马羊猴鸡狗猪"
LSJZ = Split(tt)
'On Error Resume Next
'---------------------------------------------------------------------------------以上为变量定义
yy = Year(birth): mm = month(birth): dd = Day(birth): hh = Hour(birth)
birth1 = birth + 1 / 24: yy1 = yy - 4: birth2 = DateSerial(yy, 2, 1)
lichun = getjq(birth2, , 4) '立春
'---------------------------------------------------------------------------------年柱已经调试好
If lichun > birth Then yy1 = yy1 - 1
nzhu = LSJZ(yy1 Mod 60): shux = Mid(SX, (yy1 Mod 12) + 1, 1)
'---------------------------------------------------------------------------------月柱已经调试好
yue = getjq(birth, 2)
If yue < 2 Then yy1 = yy1 - 4
yzhu = LSJZ((yue + yy1 * 12) Mod 60)
'---------------------------------------------------------------------------------日柱已经调试好
rcs = (Int(birth1) + 8) Mod 60
rzhu = LSJZ(rcs)
'---------------------------------------------------------------------------------时柱已经调试好
szhu = LSJZ((Int(birth) * 12 + 36 + hh / 2 + 1 / 12) Mod 60)
'------------------------------------------------------------------------------------结果输出
sizhu = nzhu & "年 " & yzhu & "月 " & rzhu & "日 " & szhu & "时"
sizhu1 = nzhu & "年" & yzhu & "月" & rzhu & "日"
sizhu = Choose(gs + 1, sizhu, nzhu, yzhu, rzhu, szhu, shux, sizhu1)
End Function |
评分
-
1
查看全部评分
-
|