If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > Inserting at selection

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-23-04, 15:50
juststo juststo is offline
Registered User
 
Join Date: Sep 2004
Posts: 14
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
Reply With Quote
  #2 (permalink)  
Old 09-23-04, 22:08
savbill savbill is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 09-24-04, 11:23
juststo juststo is offline
Registered User
 
Join Date: Sep 2004
Posts: 14
Thanks!!! That's it.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On