忍者ブログ
まにょのITメモ
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。


Sub Macro1()
'
' Macro1 Macro
' マクロ記録日 : 2010/1/23
'
    'データの空行指定
    Dim emptyRow: emptyRow = 1
    Dim koteiCell: koteiCell = "A"
    ' 現在選択されている行を保持
    Dim startRow: startRow = 0
    Dim endRow: endRow = 0
    Dim r As Range
    Dim count As Integer
   
    For Each r In Range(Selection.Address)
        If count = 0 Then
            startRow = r.Row
        End If
        endRow = r.Row
        count = count + 1
    Next
   
    'Range(Selection, Selection.End(xlUp)).Select
   
    Dim sabun: sabun = endRow - startRow
    Range(Cells(endRow + 1, 2), Cells(endRow + emptyRow + sabun, 4)).EntireRow.Insert
   
    Range(Selection, Selection.End(xlToRight)).Select
    Selection.Cut
   
    '挿入する場所を指定
    Range(koteiCell & endRow + 1).Select
    ActiveSheet.Paste
    Selection.End(xlToLeft).Select
End Sub
PR
忍者ブログ * [PR]