您好,欢迎访问三七文档
当前位置:首页 > 临时分类 > excel农历转换公式
excel农历转换公式1、如何在本计算机中的其他文件中使用?在VB编辑器中添加一个“模块”将文档里的红色代码加入其中,请将此文件另存为加载宏(保存类型中最后一个)然后在菜单工具-加载宏中选择后即可2、如何使用函数?像其他函数一样用就行如下截图:PublicFunctionNongLi(OptionalXX_DATEAsDate)DimMonthAdd(11),NongliData(99),TianGan(9),DiZhi(11),ShuXiang(11),DayName(30),MonName(12)DimcurTime,curYear,curMonth,curDayDimGongliStr,NongliStr,NongliDayStrDimi,m,n,k,isEnd,bit,TheDate'获取当前系统时间curTime=XX_DATE'天干名称TianGan(0)=甲TianGan(1)=乙TianGan(2)=丙TianGan(3)=丁TianGan(4)=戊TianGan(5)=己TianGan(6)=庚TianGan(7)=辛TianGan(8)=壬TianGan(9)=癸'地支名称DiZhi(0)=子DiZhi(1)=丑DiZhi(2)=寅DiZhi(3)=卯DiZhi(4)=辰DiZhi(5)=巳DiZhi(6)=午DiZhi(7)=未DiZhi(8)=申DiZhi(9)=酉DiZhi(10)=戌DiZhi(11)=亥'属相名称ShuXiang(0)=鼠ShuXiang(1)=牛ShuXiang(2)=虎ShuXiang(3)=兔ShuXiang(4)=龙ShuXiang(5)=蛇ShuXiang(6)=马ShuXiang(7)=羊ShuXiang(8)=猴ShuXiang(9)=鸡ShuXiang(10)=狗ShuXiang(11)=猪'农历日期名DayName(0)=*DayName(1)=初一DayName(2)=初二DayName(3)=初三DayName(4)=初四DayName(5)=初五DayName(6)=初六DayName(7)=初七DayName(8)=初八DayName(9)=初九DayName(10)=初十DayName(11)=十一DayName(12)=十二DayName(13)=十三DayName(14)=十四DayName(15)=十五DayName(16)=十六DayName(17)=十七DayName(18)=十八DayName(19)=十九DayName(20)=二十DayName(21)=廿一DayName(22)=廿二DayName(23)=廿三DayName(24)=廿四DayName(25)=廿五DayName(26)=廿六DayName(27)=廿七DayName(28)=廿八DayName(29)=廿九DayName(30)=三十'农历月份名MonName(0)=*MonName(1)=正MonName(2)=二MonName(3)=三MonName(4)=四MonName(5)=五MonName(6)=六MonName(7)=七MonName(8)=八MonName(9)=九MonName(10)=十MonName(11)=十一MonName(12)=腊'公历每月前面的天数MonthAdd(0)=0MonthAdd(1)=31MonthAdd(2)=59MonthAdd(3)=90MonthAdd(4)=120MonthAdd(5)=151MonthAdd(6)=181MonthAdd(7)=212MonthAdd(8)=243MonthAdd(9)=273MonthAdd(10)=304MonthAdd(11)=334'农历数据NongliData(0)=2635NongliData(1)=333387NongliData(2)=1701NongliData(3)=1748NongliData(4)=267701NongliData(5)=694NongliData(6)=2391NongliData(7)=133423NongliData(8)=1175NongliData(9)=396438NongliData(10)=3402NongliData(11)=3749NongliData(12)=331177NongliData(13)=1453NongliData(14)=694NongliData(15)=202126NongliData(16)=2350NongliData(17)=465197NongliData(18)=3221NongliData(19)=3402NongliData(20)=400202NongliData(21)=2901NongliData(22)=1386NongliData(23)=267611NongliData(24)=605NongliData(25)=2349NongliData(26)=137515NongliData(27)=2709NongliData(28)=464533NongliData(29)=1738NongliData(30)=2901NongliData(31)=330421NongliData(32)=1242NongliData(33)=2651NongliData(34)=199255NongliData(35)=1323NongliData(36)=529706NongliData(37)=3733NongliData(38)=1706NongliData(39)=398762NongliData(40)=2741NongliData(41)=1206NongliData(42)=267438NongliData(43)=2647NongliData(44)=1318NongliData(45)=204070NongliData(46)=3477NongliData(47)=461653NongliData(48)=1386NongliData(49)=2413NongliData(51)=1197NongliData(52)=2637NongliData(53)=268877NongliData(54)=3365NongliData(55)=531109NongliData(56)=2900NongliData(57)=2922NongliData(58)=398042NongliData(59)=2395NongliData(60)=1179NongliData(61)=267415NongliData(62)=2635NongliData(63)=661067NongliData(64)=1701NongliData(65)=1748NongliData(66)=398772NongliData(67)=2742NongliData(68)=2391NongliData(69)=330031NongliData(70)=1175NongliData(71)=1611NongliData(72)=202110NongliData(73)=3749NongliData(74)=527717NongliData(75)=1452NongliData(76)=2742NongliData(77)=332397NongliData(78)=2350NongliData(79)=3222NongliData(80)=268949NongliData(81)=3402NongliData(82)=3493NongliData(83)=133973NongliData(84)=1386NongliData(85)=464219NongliData(86)=605NongliData(87)=2349NongliData(88)=334123NongliData(89)=2709NongliData(90)=2890NongliData(91)=267946NongliData(92)=2773NongliData(93)=592565NongliData(95)=2651NongliData(96)=395863NongliData(97)=1323NongliData(98)=2707NongliData(99)=265877'生成当前公历年、月、日==GongliStrcurYear=Year(curTime)curMonth=Month(curTime)curDay=Day(curTime)GongliStr=curYear&年If(curMonthGongliStr=GongliStr&0&curMonth&月ElseGongliStr=GongliStr&curMonth&月EndIfIf(curDayGongliStr=GongliStr&0&curDay&日ElseGongliStr=GongliStr&curDay&日EndIf'计算到初始时间1921年2月8日的天数:1921-2-8(正月初一)TheDate=(curYear-1921)*365+Int((curYear-1921)/4)+curDay+MonthAdd(curMonth-1)-38If((curYearMod4)=0AndcurMonth2)ThenTheDate=TheDate+1EndIf'计算农历天干、地支、月、日isEnd=0m=0DoIf(NongliData(m)k=11Elsek=12EndIfn=kDoIf(nExitDoEndIf'获取NongliData(m)的第n个二进制位的值bit=NongliData(m)Fori=1TonStep1bit=Int(bit/2)Nextbit=bitMod2If(TheDateisEnd=1ExitDoEndIfTheDate=TheDate-29-bitn=n-1LoopIf(isEnd=1)ThenExitDoEndIfm=m+1LoopcurYear=1921+mcurMonth=k-n+1curDay=TheDateIf(k=12)ThenIf(curMonth=(Int(NongliData(m)/65536)+1))ThencurMonth=1-curMonthElseIf(curMonth(Int(NongliData(m)/65536)+1))ThencurMonth=curMonth-1EndIfEndIf'生成农历天干、地支、属相==NongliStrNongliStr=农历&TianGan(((curYear-4)Mod60)Mod10)&DiZhi(((curYear-4)Mod60)Mod12)&年NongliStr=NongliStr&(&ShuXiang(((curYear-4)Mod60)Mod12)&)'生成农历月、日==NongliDayStrIf(curMonthNongliDayStr=闰&MonName(-1*curMonth)ElseNongliDayStr=MonName(curMonth)EndIfNongliDayStr=NongliDayStr&月NongliDayStr=NongliDayStr&DayName(curDay)NongLi=NongliStr&NongliDayStrEndFunction
本文标题:excel农历转换公式
链接地址:https://www.777doc.com/doc-7845622 .html