Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Swap 2 lines
What would be the best way, in code, to swap entire lines 19 and 20 in sheet1 ? Thanks - Kirk |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Swap 2 lines
Hi,
Right click your sheet tab, view code and paste this in and run it Sub Sonic() Rows(20).Insert Shift:=xlDown Cells(19, 1).EntireRow.Copy Destination:=Cells(20, 1) Cells(21, 1).EntireRow.Copy Destination:=Cells(19, 1) Rows(21).EntireRow.Delete End Sub Mike "kirkm" wrote: What would be the best way, in code, to swap entire lines 19 and 20 in sheet1 ? Thanks - Kirk |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Swap 2 lines
Hi
Select the two row number headings and run this Sub swaprow() Dim Row1 As Range, Row2 As Range Dim Temp1 As Variant, Temp2 As Variant Set Row1 = Selection.Areas(1) Set Row2 = Selection.Areas(2) Temp1 = Row1.Value Temp2 = Row2.Value Row1.Value = Temp2 Row2.Value = Temp1 Set Row1 = Nothing Set Row2 = Nothing End Sub regards Paul On Mar 13, 8:02*am, kirkm wrote: What would be the best way, in code, *to swap entire *lines 19 and 20 in sheet1 ? Thanks - Kirk |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Swap 2 lines
Sub Short()
Rows("19:19").Cut Rows("21:21").Insert Shift:=xlDown End Sub "kirkm" wrote: What would be the best way, in code, to swap entire lines 19 and 20 in sheet1 ? Thanks - Kirk |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Swap 2 lines
Thanks very much everyone!
Interesting to see the different methods and mission accomplished this end ! Cheers - Kirk |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
swap | Excel Worksheet Functions | |||
Swap the X and Y axes | Charts and Charting in Excel | |||
swap axes | Charts and Charting in Excel | |||
Swap Cells | Excel Discussion (Misc queries) | |||
Last, First Name Swap | Excel Programming |