すぐマク YNxv983625 Home | Search | Contents | Gallery | Introduction | Service | Support | What's New!
セルの値から年を和暦で取得するには?
Question 60.9 値の操作 Excel VBA Borad (掲示板)より Previous Next
どなたか教えて下さい。
Year(日付)とすると、西暦の値が返ってきますよね? 例えば(日付)が「平成15年4月1日」だとすると、値は「2003」が返ってくると思います。
でわなくて、「平成15年」の「15」の値がほしいのですが、サクッとできる方法はないでしょうか?
Answer   2003.6.5 がまがえる
書式設定で日付関数の "e" は平成15年の15です。
    Range("a2").Select
    Selection.NumberFormatLocal = "e"
    d = Range("a2").Text
value ではなく Text を使えばOK
ありがとうございました
すごいサクッとできました
http://www.geocities.jp/happy_ngi/ Home | Contents | Gallery | Introduction | Service | Support | What's New!

Click here to visit our sponsor