Re: Excel Question: Swapping Rows

  • From: "Dale Leavens" <dleavens@xxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Fri, 11 Mar 2011 07:56:34 -0500

I haven't done this particular activity but you should be able to achieve it 
using Excel macros.

I can never remember all of the syntax of the language so I use the macro 
record feature in the tools menu for such things after first practicing most of 
the moves in advance. Something as big as this I might bang out some of the 
instructions on my Perkins to keep me in order as I go with the recording then 
edit the macro to refine it or add stuff as needed.

There are probably many ways to do this as there usually are. In this case you 
will want to position the cursor on the first row you want to swap. If it will 
be the same row every time you need this then begin the recording and use the 
CTRL+G (goto) command to locate the row or column. Then select that entire row 
and CTRL+X cut it to the clipboard. Then move to the row you want to swap to 
and paste it there.

Then select and cut to clipboard the other row and move the cursor to the line 
where it is to appear and paste it there.

Now stop the macro recorder.

During the initiation of the recording of the macro you can assign a shortcut 
key to initiate the macro.

If you are going to use the same set of rows or columns each time that would be 
about it. If you want to select different ones to swap you will need to include 
an input box of some sort where you can enter the row or column numbers to be 
swapped.

I haven't used Excel macros as much as I have Word macros and I am a lot less 
familiar with the vast number of manipulations available to Excel as I am with 
Word but generally anything you can manipulate within the programme is 
available to the macros.

Hope this is helpful.


----- Original Message ----- 
  From: Homme, James 
  To: programmingblind@xxxxxxxxxxxxx 
  Sent: Friday, March 11, 2011 7:15 AM
  Subject: Excel Question: Swapping Rows


  Hi,

  I would love to be able to press one key and move a row up or down in Excel 
2007. One key would swap with the row above. The other would swap with the row 
below. I'd like to do the same for columns. One would swap with the column to 
the right. The other would swap with the column to the left. I'd like to have 
this set of functions work for every workbook. Now for the $64 question. How 
difficult is this to create, and how do you do it? 

   

  Thanks.

   

  Jim



------------------------------------------------------------------------------
  This e-mail and any attachments to it are confidential and are intended 
solely for use of the individual or entity to whom they are addressed. If you 
have received this e-mail in error, please notify the sender immediately and 
then delete it. If you are not the intended recipient, you must not keep, use, 
disclose, copy or distribute this e-mail without the author's prior permission. 
The views expressed in this e-mail message do not necessarily represent the 
views of Highmark Inc., its subsidiaries, or affiliates.

Other related posts: