Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 16: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, 23:08
savbill savbill is offline
Registered User
 
Join Date: Feb 2004
Posts: 525
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, 12: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

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