|
楼主 |
发表于 2018-11-9 15:44
|
显示全部楼层
本帖最后由 zopey 于 2018-11-9 17:10 编辑
八字反推代码如下, 红色部分为 修正后代码。(上楼层附件代码有 些许错误, 请自行更新)
Sub test2()
Rows("3:65535").ClearContents
Dim LSJZ
tt$ = "甲子 乙丑 丙寅 丁卯 戊辰 已巳 庚午 辛未 壬申 癸酉 甲戌 乙亥 " _
& "丙子 丁丑 戊寅 已卯 庚辰 辛巳 壬午 癸未 甲申 乙酉 丙戌 丁亥 " _
& "戊子 已丑 庚寅 辛卯 壬辰 癸巳 甲午 乙未 丙申 丁酉 戊戌 已亥 " _
& "庚子 辛丑 壬寅 癸卯 甲辰 乙巳 丙午 丁未 戊申 已酉 庚戌 辛亥 " _
& "壬子 癸丑 甲寅 乙卯 丙辰 丁巳 戊午 已未 庚申 辛酉 壬戌 癸亥"
LSJZ = Split(tt)
Dim i As Long, lichun As String, jieqi As String
bazi = [B1]
yy1 = Left([B1], 2)
yz2 = Mid([B1], 5, 2)
rz3 = Mid([B1], 9, 2)
hh = DateDiff("n", "12:00", [a1]) / 1440
Dim k1 As Long
For i = 0 To 59
If LSJZ(i) = yy1 Then k1 = i + 4: k3 = k3 + 1
If LSJZ(i) = yz2 Then k2 = (i - 1) Mod 12: k3 = k3 + 1
If k2 < 0 Then k2 = k2 + 12
If k3 = 2 Then Exit For
Next
''''''''''''
k4 = 2
Dim j As Double
For i = k1 To 2200 Step 60
jieqi1 = Int(getjq(i, k2 * 2)) - 2
jieqi2 = Int(getjq(i, (k2 + 1) * 2)) + 2
For j = jieqi1 To jieqi2
If sizhu(JD2GL(j + hh)) = bazi Then
k4 = k4 + 1
Cells(k4, 1) = JD2GL(j + hh)
Cells(k4, 2) = sizhu(JD2GL(j + hh))
Exit For
End If
Next j
Next i
End Sub
|
|