資源描述:
《excel公歷轉農(nóng)歷的四種方法.doc》由會員上傳分享,免費在線閱讀,更多相關內(nèi)容在行業(yè)資料-天天文庫。
1、..excel公歷轉農(nóng)歷的四種方法excel公歷轉農(nóng)歷方法一:使用text函數(shù) A列是公歷日期,我們在B1單元格輸入公式:=TEXT(A1,"[$-130000]yyyy年m月"&IF(LEN(--TEXT(A1,"[$-130000]dd"))=1,"初","")&"d"),下拉完成公歷轉農(nóng)歷。excel公歷轉農(nóng)歷方法二:使用text+MID函數(shù) A列仍然是公歷,B1輸入公式:=MID("甲乙丙丁戊己庚辛壬癸",MOD(TEXT(A1,"[$-130000]e")-4,10)+1,1)&MID("子丑寅卯辰巳午未申酉戌亥",M
2、OD(TEXT(A1,"[$-130000]e")-4,12)+1,1)&"年"&TEXT(A1,"[$-130000][DBNum1]m月d日"即可。excel公歷轉農(nóng)歷方法三:使用text+MID+CHOOSE+YEAR函數(shù) A1為公歷,B1輸入:=CHOOSE(MOD(YEAR(A1)-1900,10)+1,"庚","辛","壬","癸","甲","乙","丙","丁","戊","己")&CHOOSE(MOD(YEAR(A1)-1900,12)+1,"子","丑","寅","卯","辰","巳","午","未","申","酉
3、","戌","亥")&TEXT(A1,"[dbnum1][$-130000]年m月"&IF(--TEXT(A1,"[$-130000]d")<11,"初","")&TEXT(A1,"[dbnum1][$-130000]d"))excel公歷轉農(nóng)歷方法四:使用自定義函數(shù) 上面介紹的excel公歷轉農(nóng)歷都是使用excel內(nèi)置函數(shù)完成的,有一個弊端就是公式太長,如果使用自定義函數(shù),在公式欄就可以簡化輸入?! ∪缦聢D所示,我們在B2輸入公式:=nongli(A2),即可。C列農(nóng)歷簡稱中C2公式是:=RIGHT(B2,LEN(B2)-8)。
4、.下載可編輯... 關于自定義函數(shù)的使用方法請參考:excel自定義函數(shù)添加和使用方法 下面是此自定義函數(shù)相關的代碼: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
5、,k,isEnd,bit,TheDate'獲取當前系統(tǒng)時間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)=.下載可編輯
6、..."巳"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)="豬"'農(nóng)
7、歷日期名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)="十六"DayN
8、ame(17)="十七"DayName(18)="十八"DayName(19)="十九"DayName(20)="二十"DayName(21)="廿一"DayName(22)="廿二"DayName(23)=.下載可編輯..."廿三"