Paulus1983
New Member
- Joined
- Jan 7, 2008
- Messages
- 12
Hello,
Not too long ago I posted the following question:
http://www.mrexcel.com/forum/showthread.php?p=2647298#post2647298
what will a macro look like that allows me to copy the final row from a specific range (eg. B5:M27) to the next row. So I'm looking for a macro that searches for the final row in a pre-set range and copies this row to the next, when the macro is activated.
In the example above the final row can be ranging from 5 to 27.
And received the following Macro as an answer:
Sub CopyRow()
Last = Cells(Rows.Count, "B").End(xlUp).Row
With Cells(Last, "B")
.Offset(1, 0).Value = Cells(Last, "B").Value
.Offset(1, 1).Value = .Offset(, 1).Value
.Offset(1, 2).Value = .Offset(, 2).Value
.Offset(1, 3).Value = .Offset(, 3).Value
.Offset(1, 4).Value = .Offset(, 4).Value
.Offset(1, 5).Value = .Offset(, 5).Value
.Offset(1, 6).Value = .Offset(, 6).Value
.Offset(1, 7).Value = .Offset(, 7).Value
.Offset(1, 8).Value = .Offset(, 8).Value
.Offset(1, 9).Value = .Offset(, 9).Value
.Offset(1, 10).Value = .Offset(, 10).Value
.Offset(1, 11).Value = .Offset(, 11).Value
.Offset(1, 12).Value = .Offset(, 12).Value
End With
End Sub
This worked great but I would like to change the criteria. Instead of determining the row to copy based on the final row that contains data in column B, I would like to determine the row to copy based on the cell selected in column A.
eg. if the relevant range is B5:M27 and A8 is selected, the macro should copy B8:M8 and past it to the next.
Thank you very much for all help!
Not too long ago I posted the following question:
http://www.mrexcel.com/forum/showthread.php?p=2647298#post2647298
what will a macro look like that allows me to copy the final row from a specific range (eg. B5:M27) to the next row. So I'm looking for a macro that searches for the final row in a pre-set range and copies this row to the next, when the macro is activated.
In the example above the final row can be ranging from 5 to 27.
And received the following Macro as an answer:
Sub CopyRow()
Last = Cells(Rows.Count, "B").End(xlUp).Row
With Cells(Last, "B")
.Offset(1, 0).Value = Cells(Last, "B").Value
.Offset(1, 1).Value = .Offset(, 1).Value
.Offset(1, 2).Value = .Offset(, 2).Value
.Offset(1, 3).Value = .Offset(, 3).Value
.Offset(1, 4).Value = .Offset(, 4).Value
.Offset(1, 5).Value = .Offset(, 5).Value
.Offset(1, 6).Value = .Offset(, 6).Value
.Offset(1, 7).Value = .Offset(, 7).Value
.Offset(1, 8).Value = .Offset(, 8).Value
.Offset(1, 9).Value = .Offset(, 9).Value
.Offset(1, 10).Value = .Offset(, 10).Value
.Offset(1, 11).Value = .Offset(, 11).Value
.Offset(1, 12).Value = .Offset(, 12).Value
End With
End Sub
This worked great but I would like to change the criteria. Instead of determining the row to copy based on the final row that contains data in column B, I would like to determine the row to copy based on the cell selected in column A.
eg. if the relevant range is B5:M27 and A8 is selected, the macro should copy B8:M8 and past it to the next.
Thank you very much for all help!