0
votes

i am new to this site and absolutely new to using vba in excel. I need to copy about 91 rows of data from Sheet1 to Sheet2. However, the last row of sheet1 needs to be the first row of sheet2. Then the 90th row of sheet1 to be 2nd row of sheet2 and so on, till the 1st row of sheet1 becomes the last row on sheet2, Can anybody please let me know of a solution to do the same using a macro?

3

3 Answers

0
votes

Depending the range, a code like this could help you:

Sheet1.Range("a1").End(xlDown).Copy Sheet2.Range("a1")
0
votes

You can try the code below. I used a simple test set of data where row A contained column headers and the rest was the data. This uses row A's data in order to determine how many rows there are (the End(xlDown) portion), so it only works if there are no blanks in that column. It pastes data to Sheet2, starting at A2 (again, assuming there are headers in there). If you don't need headers, you can adjust accordingly.

Sub CopyStuff()

Dim MyRange As Range
Dim MySheet As Worksheet

' Declare your variables (adjust MyRange to what you want)
' I used some test data where row A contained headers
' and the data followed
Set CurSheet = ActiveWorkbook.ActiveSheet
Set DestSheet = ActiveWorkbook.Sheets("Sheet2")
Set MyRange = CurSheet.Range("A2:E" & Range("A1").End(xlDown).Row)

' Set the number of rows in your range, minus the headers
RowCount = MyRange.Rows.Count - 1

' Iterate through the rows, pasting in reverse
' This starts pasting at A2, assuming headers are in A1
For i = 1 To RowCount
  MyRange.Rows(RowCount + 2 - i).Copy DestSheet.Range("A" & i + 1)
Next i

End Sub
0
votes

Copy sheet1 data to sheet2. Add extra column say 'Number (#)'and start numbering it from row 1 till the end. Then add filter to 'Number (#)' column and sort it in descending order. Hope that helps!