+ Reply to Thread
Results 1 to 6 of 6

Switch the contents of two cells around

  1. #1
    Registered User
    Join Date
    04-30-2004
    Posts
    78

    Switch the contents of two cells around

    I have a list of ID numbers in a single column and would like to be able to switch any two of the ID's so that ID1 is moved to where ID2 was and ID2 is moved to where ID1 was. Can I possibly get a macro to do this after selecting both cells using the Ctrl key?
    Last edited by nebb; 08-27-2011 at 01:01 PM.

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Switch the contents of two cells around

    Please Login or Register  to view this content.



  3. #3
    Registered User
    Join Date
    04-30-2004
    Posts
    78

    Re: Switch the contents of two cells around

    To snb:
    I tried your subroutine but it did not produce the results I was looking for. The result of the subroutine was a switch of the contents of the first selected cell with the cell just below the first selected cell instead of with the second selected cell.
    Thanks for your help.

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Switch the contents of two cells around

    How about this

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  5. #5
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Switch the contents of two cells around

    Or

    Please Login or Register  to view this content.
    EDIT: Looking at mine and Mike's, you probably want one or the other; they are not interchangeable if either cell contains a formula.

    Mike's preserves relative cell references; mine preserves formulas exactly as-is. Either could be what you want.
    Last edited by shg; 08-27-2011 at 12:43 PM.
    Entia non sunt multiplicanda sine necessitate

  6. #6
    Registered User
    Join Date
    04-30-2004
    Posts
    78

    Re: Switch the contents of two cells around

    To Mikerickson & shg:
    Both subroutines provided the desired results. My thanks to both of you!!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1