LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Swap part of 2 columns

Select the data in the first column (or both, it doesn't matter), and
run the following code.

Sub Swap()
Dim R As Range
Dim V As Variant
For Each R In Selection.Columns(1).Cells
V = R(1, 1).Value2
R(1, 1).Value = R(1, 2).Value2
R(1, 2).Value = V
Next R
End Sub

This assumes that the selection has one area, no formulas, no merged
cells, etc, just values. Data is swapped but formatting is not.

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]






On Wed, 13 Jan 2010 06:05:01 -0800, QB
wrote:

I would like to select a range comprising 2 columns (ie: a13:B34) and click a
button and it would swap the values (ie: a13 would become b13 and b13 would
become a13 for row 13 through 34. How would I code such a feat?

Thank you,

QB

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I swap data in columns and rows around? Monkeroo New Users to Excel 2 May 28th 10 03:16 PM
How to swap the contents rows and columns in a spreadsheet? Andrew Excel Worksheet Functions 2 March 28th 09 04:00 PM
swap rows and columns rudyh Excel Discussion (Misc queries) 3 December 15th 05 01:23 AM
How to swap rows and columns? [email protected] Excel Discussion (Misc queries) 5 September 21st 05 08:07 AM
Swap columns A&B with C&D Cory Thomas[_8_] Excel Programming 2 June 16th 04 12:34 AM


All times are GMT +1. The time now is 04:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"