Sub日付け変更 ()
Dim cell As Range
Dim originalDate As String
Dim convertedDate As String
' 変換したいセルの範囲を指定
For Each cell In Selection
' セルの値を取得
originalDate = cell.Value
' yyyymmdd形式からyyyy/mm/dd形式に変換
If Len(originalDate) = 8 Then
convertedDate = Left(originalDate, 4) & "/" & Mid(originalDate, 5, 2) & "/" & Right(originalDate, 2)
cell.Value = convertedDate
Else
MsgBox "Invalid date format in cell " & cell.Address
End If
Next cell
End Sub