Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() Chip Pearson wrote: You can do it with VBA: Dim V1 As Variant Dim V2 As Variant V1 = Range("1:1").Value V2 = Range("2:2").Value Range("1:1").Value = V2 Range("2:2").Value = V1 -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com Thanks that exchanges row 1 and row2. The next question would be how can I get the macro to accept two parameters i and j and then exchange row i and row j ? Thanks. wrote in message oups.com... Is there a quick way to switch the contents of two rows ? Thanks. |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Try something like
Dim V1 As Variant Dim V2 As Variant Dim I As Integer Dim J As Integer I = 5 J = 10 V1 = Range(I & ":" & I).Value V2 = Range(J & ":" & J).Value Range(I & ":" & I).Value = V2 Range(J & ":" & J).Value = V1 -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com wrote in message ups.com... Chip Pearson wrote: You can do it with VBA: Dim V1 As Variant Dim V2 As Variant V1 = Range("1:1").Value V2 = Range("2:2").Value Range("1:1").Value = V2 Range("2:2").Value = V1 -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com Thanks that exchanges row 1 and row2. The next question would be how can I get the macro to accept two parameters i and j and then exchange row i and row j ? Thanks. wrote in message oups.com... Is there a quick way to switch the contents of two rows ? Thanks. |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]() Chip Pearson wrote: Try something like Dim V1 As Variant Dim V2 As Variant Dim I As Integer Dim J As Integer I = 5 J = 10 V1 = Range(I & ":" & I).Value V2 = Range(J & ":" & J).Value Range(I & ":" & I).Value = V2 Range(J & ":" & J).Value = V1 Now I get "out of stack space". Also is there any way I can invoke the macro with I and J as input parameters ? Thanks again. (after all there is a dumb way to do it - I just wanted to knoe if there was a fairly short way). -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com wrote in message ups.com... Chip Pearson wrote: You can do it with VBA: Dim V1 As Variant Dim V2 As Variant V1 = Range("1:1").Value V2 = Range("2:2").Value Range("1:1").Value = V2 Range("2:2").Value = V1 -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com Thanks that exchanges row 1 and row2. The next question would be how can I get the macro to accept two parameters i and j and then exchange row i and row j ? Thanks. wrote in message oups.com... Is there a quick way to switch the contents of two rows ? Thanks. |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Try
Sub SwapRows(I As Integer, J As Integer) Dim V1 As Variant Dim V2 As Variant On Error GoTo ErrH Application.EnableEvents = False V1 = Range(I & ":" & I).Value V2 = Range(J & ":" & J).Value Range(I & ":" & I).Value = V2 Range(J & ":" & J).Value = V1 ErrH: Application.EnableEvents = True End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com wrote in message oups.com... Chip Pearson wrote: Try something like Dim V1 As Variant Dim V2 As Variant Dim I As Integer Dim J As Integer I = 5 J = 10 V1 = Range(I & ":" & I).Value V2 = Range(J & ":" & J).Value Range(I & ":" & I).Value = V2 Range(J & ":" & J).Value = V1 Now I get "out of stack space". Also is there any way I can invoke the macro with I and J as input parameters ? Thanks again. (after all there is a dumb way to do it - I just wanted to knoe if there was a fairly short way). -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com wrote in message ups.com... Chip Pearson wrote: You can do it with VBA: Dim V1 As Variant Dim V2 As Variant V1 = Range("1:1").Value V2 = Range("2:2").Value Range("1:1").Value = V2 Range("2:2").Value = V1 -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com Thanks that exchanges row 1 and row2. The next question would be how can I get the macro to accept two parameters i and j and then exchange row i and row j ? Thanks. wrote in message oups.com... Is there a quick way to switch the contents of two rows ? Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to swap rows and columns? | Excel Discussion (Misc queries) | |||
Hiding Rows if the linked rows are blank | Excel Discussion (Misc queries) | |||
How can I switch so that rows are referenced with letters, and co. | Excel Discussion (Misc queries) | |||
Switch Rows and Columns | Excel Discussion (Misc queries) | |||
flexible paste rows function that inserts the right number of rows | Excel Discussion (Misc queries) |