Moving the second row to the last row

M

Max2073

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.
 
S

Stefi

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:
 
S

Stefi

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


„Stefi†ezt írta:
 
J

Jacob Skaria

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
 
J

Jacob Skaria

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top