Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I swap data in columns and rows around? | New Users to Excel | |||
How to swap the contents rows and columns in a spreadsheet? | Excel Worksheet Functions | |||
swap rows and columns | Excel Discussion (Misc queries) | |||
How to swap rows and columns? | Excel Discussion (Misc queries) | |||
Swap columns A&B with C&D | Excel Programming |