ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Moving the second row to the last row (https://www.excelbanter.com/excel-worksheet-functions/243730-moving-second-row-last-row.html)

Max2073

Moving the second row to the last row
 
Hi,

I would like to create a macro that moves the second row to the last row in
the worksheet. The worksheet varies in the number of rows and I can not work
out if this is possible or how to do it.



Stefi

Moving the second row to the last row
 
Sub Macro1()
lastrow = Range("A" & Rows.Count).End(xlUp).Row
Rows("2:2").Cut
Rows(lastrow + 1).Insert Shift:=xlDown
End Sub

Regards,
Stefi

€˛Max2073€¯ ezt Ć*rta:

Hi,

I would like to create a macro that moves the second row to the last row in
the worksheet. The worksheet varies in the number of rows and I can not work
out if this is possible or how to do it.



Stefi

Moving the second row to the last row
 
Forgot to mention that the cell in column A, last row must not be empty!
Stefi


€˛Stefi€¯ ezt Ć*rta:

Sub Macro1()
lastrow = Range("A" & Rows.Count).End(xlUp).Row
Rows("2:2").Cut
Rows(lastrow + 1).Insert Shift:=xlDown
End Sub

Regards,
Stefi

€˛Max2073€¯ ezt Ć*rta:

Hi,

I would like to create a macro that moves the second row to the last row in
the worksheet. The worksheet varies in the number of rows and I can not work
out if this is possible or how to do it.



Jacob Skaria

Moving the second row to the last row
 
If you are only looking at moving Row 2 to the last position (without
shifting cells) then try the below code.

Sub Macro()
Rows(2).Cut Rows(Range("A" & Rows.Count).End(xlUp).Row + 1)
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Max2073" wrote:

Hi,

I would like to create a macro that moves the second row to the last row in
the worksheet. The worksheet varies in the number of rows and I can not work
out if this is possible or how to do it.



Jacob Skaria

Moving the second row to the last row
 
If column A data is not the last row; then try the below macro

Sub Macro1()
Dim lngLastRow As Long

lngLastRow = ActiveSheet.Cells.Find(What:="*", _
SearchDirection:=xlPrevious, SearchOrder:=xlRows).Row
'to move to last row
Rows(2).Cut Rows(lngLastRow + 1)

'OR - to move to last+1 row and shift
'Rows(2).Cut
'Rows(lngLastRow + 1).Insert Shift:=xlDown
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"Max2073" wrote:

Hi,

I would like to create a macro that moves the second row to the last row in
the worksheet. The worksheet varies in the number of rows and I can not work
out if this is possible or how to do it.




All times are GMT +1. The time now is 07:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com