《excel制作周历 农历阳历转换.docx》由会员分享,可在线阅读,更多相关《excel制作周历 农历阳历转换.docx(11页珍藏版)》请在金锄头文库上搜索。
1、步骤一,在Excel工作表界面下按组合键打开VBA窗口,进入VBA编辑环境,在其窗口的菜单栏上依次单击“插入”“模块”,可在当前VBA工程中插入模块,并直接进入此模块的代码编辑区域。可在此编辑区域中输入自定义函数的程序代码,如图:Public Function NongLi(Optional XX_DATE As Date)Dim MonthAdd(11), NongliData(99), TianGan(9), DiZhi(11), ShuXiang(11), DayName(30), MonName(12)Dim curTime, curYear, curMonth, curDayDim
2、GongliStr, NongliStr, NongliDayStrDim i, 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) =
3、 辰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
4、(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)
5、= 二十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) = 八MonNa
6、me(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(
7、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) = 2
8、01326NongliData(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
9、) = 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) = 267438NongliDat
10、a(43) = 2647NongliData(44) = 1318NongliData(45) = 204070NongliData(46) = 3477NongliData(47) = 461653NongliData(48) = 1386NongliData(49) = 2413NongliData(50) = 330077NongliData(51) = 1197NongliData(52) = 2637NongliData(53) = 268877NongliData(54) = 3365NongliData(55) = 531109NongliData(56) = 2900Nongl
11、iData(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) = 1175N
12、ongliData(71) = 1611NongliData(72) = 200010NongliData(73) = 3749NongliData(74) = 527717NongliData(75) = 1452NongliData(76) = 2742NongliData(77) = 332397NongliData(78) = 2350NongliData(79) = 3222NongliData(80) = 268949NongliData(81) = 3402NongliData(82) = 3493NongliData(83) = 133973NongliData(84) = 1
13、386NongliData(85) = 464219NongliData(86) = 605NongliData(87) = 2349NongliData(88) = 334123NongliData(89) = 2709NongliData(90) = 2890NongliData(91) = 267946NongliData(92) = 2773NongliData(93) = 592565NongliData(94) = 1210NongliData(95) = 2651NongliData(96) = 395863NongliData(97) = 1323NongliData(98) = 2707NongliData(99) = 265877生成当前公历年、月、日 = GongliStrcurYear = Year(curTime)curMonth = Month(curTime)curDay = Day(curTime)GongliStr = curYear & 年If (curMonth 10) ThenGongliStr = GongliStr & 0 & curMonth & 月ElseGongliStr = GongliStr & curMonth & 月End IfIf (curDay