Swap 2 lines
What would be the best way, in code, to swap entire lines 19 and 20 in sheet1 ? Thanks - Kirk |
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 |
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 |
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 |
Swap 2 lines
Thanks very much everyone!
Interesting to see the different methods and mission accomplished this end ! Cheers - Kirk |
All times are GMT +1. The time now is 03:31 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com