Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
select row(s) and shift up one place automatically
I want to swap the selected row with the one who is above. So I can
rearrange my products in the right way. In this example I swap row 3 with 2. Sub swaprows() Rows("3:3").Select Selection.Cut Rows("2:2").Select Selection.Insert Shift:=xlDown End sub But it is also possible that row 76 is swapped with row 75 depending on which row is selected by the user. And it is also possible that row 20 to 25 is selected and that it must be 19 to 24. Does anybody have an idea? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
select row(s) and shift up one place automatically
On 30 okt, 11:43, bartman1980 wrote:
I want to swap the selected row with the one who is above. So I can rearrange my products in the right way. In this example I swap row 3 with 2. Sub swaprows() Rows("3:3").Select Selection.Cut Rows("2:2").Select Selection.Insert Shift:=xlDown End sub But it is also possible that row 76 is swapped with row 75 depending on which row is selected by the user. And it is also possible that row 20 to 25 is selected and that it must be 19 to 24. Does anybody have an idea? I think I already got it: To shift up Selection.Cut Rows(ActiveCell.Row - 1 & ":" & ActiveCell.Row - 1).Select Selection.Insert Shift:=xlDown To shift down Selection.Cut Rows(ActiveCell.Row + 2 & ":" & ActiveCell.Row + 2).Select Selection.Insert Shift:=xlDown Rows(ActiveCell.Row - 1 & ":" & ActiveCell.Row - 1).Select |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
select row(s) and shift up one place automatically
On Oct 30, 11:52 pm, bartman1980 wrote:
On 30 okt, 11:43, bartman1980 wrote: I want to swap the selected row with the one who is above. So I can rearrange my products in the right way. In this example I swap row 3 with 2. Sub swaprows() Rows("3:3").Select Selection.Cut Rows("2:2").Select Selection.Insert Shift:=xlDown End sub But it is also possible that row 76 is swapped with row 75 depending on which row is selected by the user. And it is also possible that row 20 to 25 is selected and that it must be 19 to 24. Does anybody have an idea? I think I already got it: To shift up Selection.Cut Rows(ActiveCell.Row - 1 & ":" & ActiveCell.Row - 1).Select Selection.Insert Shift:=xlDown To shift down Selection.Cut Rows(ActiveCell.Row + 2 & ":" & ActiveCell.Row + 2).Select Selection.Insert Shift:=xlDown Rows(ActiveCell.Row - 1 & ":" & ActiveCell.Row - 1).Select I couldn't get your shift down to work. My attempts are... Public Sub SwapRowsUp() Selection.EntireRow.Select Selection.Cut Range(Cells(ActiveCell.Row - 1, 1), _ Cells(ActiveCell.Row + Selection.Rows.Count - 1, 1)).EntireRow.Insert _ xlDown End Sub Public Sub SwapRowsDown() Selection.EntireRow.Select Selection.Cut Range(Cells(ActiveCell.Row + 2 * Selection.Rows.Count, 1), _ Cells(ActiveCell.Row + 3 * Selection.Rows.Count - 1, 1)).EntireRow.Insert _ xlDown End Sub Ken Johnson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
After press Shift+Ctrl+Up arrw key it does not select up side Col | Excel Discussion (Misc queries) | |||
hold shift key down to select multiple cells | Excel Discussion (Misc queries) | |||
Select which cell enter will place the cursor | Excel Discussion (Misc queries) | |||
Control + Shift + Up/Down not allowing me to select multiple cells. | Excel Discussion (Misc queries) | |||
Automatically place hyphen | New Users to Excel |