View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
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