見出し画像

履歴書の平成と令和を西暦に変換するよwithChatGPT

この説明は、ChatGPTで作成しています。


このプロシージャは、Excelのセルの中にある「平成○年」や「令和○年」という文字を、対応する西暦(例:平成30年 → 2018年)に自動で変換してくれるものです。

何に使うの?

たとえば履歴書などで、「平成○年卒業」と書いてある場合、企業によっては西暦で統一しておく必要がありますよね。このマクロを使えば、自動で西暦に変換してくれるので、とても便利です!


動きの流れ(かんたん解説)

  1. 選択したセルをチェック

    • まず、Excelで選んだセルを1つずつ見ていきます。

  2. 「平成」や「令和」が入っているかを確認

    • 特別な「探し方(正規表現という方法)」で、「平成○年」や「令和○年」のような文字を探します。

  3. 見つけたら西暦に変換

    • 「平成」は1989年スタートなので、1988を足して計算します。たとえば「平成5年」なら、1988+5 = 1993年。

    • 「令和」は2019年スタートなので、2018を足して計算します。たとえば「令和2年」なら、2018+2 = 2020年。

  4. 見つけた文字を西暦に置き換える

    • 「平成30年」なら「2018年」といったように、実際のセルの文字を置き換えます。

  5. すべてのセルが終わったら終了

    • 画面の表示を止めていたのも戻します。


こんな時に使ってね!

  • 履歴書や職務経歴書を作っていて、西暦に直したいとき

  • データを会社用に整えるとき


参考リンク

Sub 履歴書の平成と令和を西暦に変換するよwithChatGPT()
    Application.ScreenUpdating = False
    Dim reg
    Set reg = CreateObject("VBScript.RegExp")   'オブジェクト作成
    With reg
        .Pattern = "(平成|令和)(\d{1,2})"
        .IgnoreCase = True
        .Global = True
    End With

    On Error Resume Next
    Dim myRng As Range
    For Each myRng In Selection
        Dim txt As String
        txt = myRng.Value
        If reg.test(txt) Then
            Dim matches, m
            Set matches = reg.Execute(txt)
            For Each m In matches
                Dim era As String
                Dim yearNum As Integer
                Dim seireki As Integer

                era = m.SubMatches(0)
                yearNum = CInt(m.SubMatches(1))

                If era = "平成" Then
                    seireki = 1988 + yearNum
                ElseIf era = "令和" Then
                    seireki = 2018 + yearNum
                End If

                txt = Replace(txt, m.Value, seireki)
            Next
        End If
        myRng.Value = txt
    Next myRng
    Application.ScreenUpdating = True
End Sub


ハッシュタグ(キーワード)

#excel #できること #vba #平成 #令和 #西暦変換 #履歴書 #正規表現 #自動変換 #年号変換 #セル処理 #文字列操作 #office活用 #事務効率化 #初心者向け #マクロ初心者 #日付変換 #vbaマクロ #ビジネス活用 #エクセル操作


English Translation

Procedure Name: 履歴書の平成と令和を西暦に変換するよwithChatGPT

This explanation was created using ChatGPT.


This procedure automatically converts "Heisei X" or "Reiwa X" in selected Excel cells into the corresponding Western calendar year. (e.g., "Heisei 30" becomes "2018").

Use Case

It's useful when you're creating resumes or formal documents that require dates in the Western calendar format.


How It Works (Simplified)

  1. Goes through each selected cell

  2. Checks if the text includes “Heisei” or “Reiwa”

    • It uses a method called regular expressions to find the pattern.

  3. Converts to Western calendar

    • Heisei: starts from 1989 → add 1988 to the year number.

    • Reiwa: starts from 2019 → add 2018 to the year number.

  4. Replaces the original text with the converted year

  5. Restores screen updating


When to Use

  • Converting dates in resumes or CVs

  • Standardizing data for company documentation


Reference Links


Hashtags

#excel #できること #vba #平成 #令和 #西暦変換 #履歴書 #正規表現 #自動変換 #年号変換 #セル処理 #文字列操作 #office活用 #事務効率化 #初心者向け #マクロ初心者 #日付変換 #vbaマクロ #ビジネス活用 #エクセル操作

いいなと思ったら応援しよう!