Option Explicit

'//IĂ̈̍sԍدްނɓ
'//قҲݳ޳̤[°][ϸ][ϸ][߼]ŤCtrl+rɊ蓖ĂĂ
'//DataObjectgpɂ͢Microsoft Forms 2.0 Object Libraryւ̎QƂKvł
Sub Selection_PutInClipboard()
        Dim iRow_First As Long
        Dim iRow_Last As Long
        Dim iColumn_First As Long
        Dim iColumn_Last As Long
        Dim s As String
        Dim cb As New DataObject
        '//I͈͂̍ŏ͈̔͂Ώۂɂ
        With Selection.Areas(1)
                '//擪sԍƐ擪ԍ擾
                With .Cells(1, 1)
                        iRow_First = .Row
                        iColumn_First = .Column
                End With
                '//ŏIsԍ擾(擪sԍ+Is-1)
                iRow_Last = iRow_First + .Rows.Count - 1
                '//ŏIԍ擾(擪ԍ+I-1)
                iColumn_Last = iColumn_First + .Columns.Count - 1
        End With
        '//ʂدްނɓ
        s = iRow_First & vbTab & iColumn_First & vbTab & iRow_Last & vbTab & iColumn_Last
        cb.SetText s
        cb.PutInClipboard
        cb.GetFromClipboard
'//     MsgBox Replace(cb.GetText, vbTab, " ")  '//J̊mFp
End Sub

'//AްĂ͈̤ٔ͂̒Ύɂ
'//قҲݳ޳̤[°][ϸ][ϸ][߼]ŤCtrl+qɊ蓖ĂĂ
Sub Selection_CurrentRegion_Absolute()
        Dim r As Range
        '//AްĂ͈ٔ͂I
        Selection.CurrentRegion.Select
        '//͈ٔ͂̐FؾĂ
        Selection.Interior.ColorIndex = xlColorIndexNone
        '//͈ٔ͂̊eقɂāc
        For Each r In Selection
                '//Ȃ΁c
                If r.HasFormula Then
                        '//Ύɂ
                        r.Formula = Application.ConvertFormula(Formula:=r.Formula, FromReferenceStyle:=xlA1, ToAbsolute:=xlAbsolute, RelativeTo:=r)
                        '//ق̐Fݒ肷
                        r.Interior.ColorIndex = 19
                '//łȂ΁c
                Else
                        '//ق̐Fݒ肷
                        r.Interior.ColorIndex = 15
                        '//ق̒l(󕶎),,//ȂΤق̐FԐFɐݒ肷
                        If (r.Value = "") Or (r.Value = "//") Then r.Interior.ColorIndex = 3
                End If
        Next
        '//͈ٔ͂̌rݒ肷
        Selection.Borders.LineStyle = xlContinuous
        '//͈̗ٔ͂񕝂ݒ肷
        Selection.Columns.AutoFit
End Sub

'//AްĂ͈̤ٔ͂̒𑊑Ύɂ
'//قҲݳ޳̤[°][ϸ][ϸ][߼]ŤCtrl+eɊ蓖ĂĂ
Sub Selection_CurrentRegion_Relative()
        Dim r As Range
        '//AްĂ͈ٔ͂I
        Selection.CurrentRegion.Select
        '//͈ٔ͂̐FؾĂ
        Selection.Interior.ColorIndex = xlColorIndexNone
        '//͈ٔ͂̊eقɂāc
        For Each r In Selection
                '//Ȃ΁c
                If r.HasFormula Then
                        '//Ύɂ
                        r.Formula = Application.ConvertFormula(Formula:=r.Formula, FromReferenceStyle:=xlA1, ToAbsolute:=xlRelative, RelativeTo:=r)
                        '//ق̐Fݒ肷
                        r.Interior.ColorIndex = 20
                '//łȂ΁c
                Else
                        '//ق̐Fݒ肷
                        r.Interior.ColorIndex = 15
                        '//ق̒l(󕶎),,//ȂΤق̐FԐFɐݒ肷
                        If (r.Value = "") Or (r.Value = "//") Then r.Interior.ColorIndex = 3
                End If
        Next
        '//͈ٔ͂̌rݒ肷
        Selection.Borders.LineStyle = xlContinuous
        '//͈̗ٔ͂񕝂ݒ肷
        Selection.Columns.AutoFit
End Sub

