Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2004
    Posts
    14

    Unanswered: Inserting at selection

    I am writing a small macro.

    Code:
    Sub Macro2()
        Rows("10:13").Select
        Application.CutCopyMode = False
        Selection.Copy
        Rows("17:17").Select
        Selection.Insert Shift:=xlDown
    End Sub
    Instead of the fifth line where I copy and insert at row 17, how can I insert at whichever row I have selected?



    Thanks

  2. #2
    Join Date
    Feb 2004
    Posts
    533
    Code:
     
    With your code when you select Rows 10:13
    that would change the current selection to rows 10 thru 13.
    This example sets a variable 'curRow' to use as the current
    selected row and does not select rows in the copy process.
    The Insert command is to be applied to row of the current
    selected cell or range.
    
    
    Sub Macro3()
        Rows("10:13").Copy
        curRow = Selection.Row
        Rows(curRow).Insert Shift:=xlDown
        CutCopyMode = False
    End Sub
    ~

    Bill

  3. #3
    Join Date
    Sep 2004
    Posts
    14
    Thanks!!! That's it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •