Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am trying to copy the last 4 rows of information to a new area from the
same sheet. The only catch is that there may be only 1 row of information or 400 rows. Either way I only want to copy the last four rows of information. For example: a b c 71 3 5 7 72 66 55 77 73 74 75 In this case I would copy rows 71 through 75 up to rows 9 through 12. Rows 9 and 10 will have information rows 11 and 12 will not. Or.... a b c 71 3 5 7 72 66 55 77 73 77 88 99 74 22 12 32 75 99 77 88 In this case Row 72 through 75 would be copied up to rows 9 through 12 with each row having some information. I was given a macro and for some reason it isn't working. Maybe someone can help me out and make it easier. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() Lastrow = Range("A" & Rows.Count).End(xlUp).Row FirstRow = Lastrow - 3 If FirstRow < 1 Then FirstRow = 1 Range("A" & FirstRow & ":C" & Lastrow).Copy _ Destination:=Range("F1") "Eric" wrote: I am trying to copy the last 4 rows of information to a new area from the same sheet. The only catch is that there may be only 1 row of information or 400 rows. Either way I only want to copy the last four rows of information. For example: a b c 71 3 5 7 72 66 55 77 73 74 75 In this case I would copy rows 71 through 75 up to rows 9 through 12. Rows 9 and 10 will have information rows 11 and 12 will not. Or.... a b c 71 3 5 7 72 66 55 77 73 77 88 99 74 22 12 32 75 99 77 88 In this case Row 72 through 75 would be copied up to rows 9 through 12 with each row having some information. I was given a macro and for some reason it isn't working. Maybe someone can help me out and make it easier. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
My first Posting assumed data was continuous from row 1 to end row, I don't
think this was correct. Try this code instead LastRow = Range("A" & Rows.Count).End(xlUp).Row FirstRow = Range("A" & LastRow).End(xlUp).Row If LastRow - FirstRow 3 Then FirstRow = LastRow - 3 End If If FirstRow < 1 Then FirstRow = 1 End If Range("A" & FirstRow & ":C" & LastRow).Copy _ Destination:=Range("F1") "Eric" wrote: I am trying to copy the last 4 rows of information to a new area from the same sheet. The only catch is that there may be only 1 row of information or 400 rows. Either way I only want to copy the last four rows of information. For example: a b c 71 3 5 7 72 66 55 77 73 74 75 In this case I would copy rows 71 through 75 up to rows 9 through 12. Rows 9 and 10 will have information rows 11 and 12 will not. Or.... a b c 71 3 5 7 72 66 55 77 73 77 88 99 74 22 12 32 75 99 77 88 In this case Row 72 through 75 would be copied up to rows 9 through 12 with each row having some information. I was given a macro and for some reason it isn't working. Maybe someone can help me out and make it easier. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
copying cells | Excel Discussion (Misc queries) | |||
Macro for copying cells above empty cells | Excel Programming | |||
copying cells by checking color of the cells | Excel Programming | |||
How do I skip blank cells when copying over a range of cells? | Excel Discussion (Misc queries) | |||
Excel should allow cloaking of certain cells when copying cells b. | Excel Worksheet Functions |