ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using .Row help please (https://www.excelbanter.com/excel-programming/415175-using-row-help-please.html)

Simon[_2_]

Using .Row help please
 
Each month I add 2 rows from the bottom of the previous month.

To do this I would like some assistance please.

I thought it would encompass

Range [A36636].Select
Selection.End(xlUp).Offset(-1, 0).Row

'then somehow select the bottom two used rows and copy them directly
underneath the copied rows

Thanks for your help. Unfortunately I have ye tto learn much about
the Row property.

Regards,

Si

Dave Peterson

Using .Row help please
 
You just want to copy the last 2 rows to the bottom of the range?

Dim RngToCopy as range
dim DestCell as range

with activesheet
set rngtocopy = .cells(.rows.count,"A").end(xlup).offset(-1,0)
set destcell = .cells(.rows.count,"A").end(xlup).offset(1,0)
end with

rngtocopy.resize(2,1).entirerow.copy _
destination:=destcell



Simon wrote:

Each month I add 2 rows from the bottom of the previous month.

To do this I would like some assistance please.

I thought it would encompass

Range [A36636].Select
Selection.End(xlUp).Offset(-1, 0).Row

'then somehow select the bottom two used rows and copy them directly
underneath the copied rows

Thanks for your help. Unfortunately I have ye tto learn much about
the Row property.

Regards,

Si


--

Dave Peterson

Don Guillett

Using .Row help please
 
I would prefer to see an example of before and after desires but maybe this
helps

preferred
myrow=cells(rows.count,"a").end(xlup).row-1

or
myrow=range("a65536").end(xlup).row-1
--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Simon" wrote in message
...
Each month I add 2 rows from the bottom of the previous month.

To do this I would like some assistance please.

I thought it would encompass

Range [A36636].Select
Selection.End(xlUp).Offset(-1, 0).Row

'then somehow select the bottom two used rows and copy them directly
underneath the copied rows

Thanks for your help. Unfortunately I have ye tto learn much about
the Row property.

Regards,

Si



J Sedoff comRemove>

Using .Row help please
 
This should work. It finds the last occupied cell in Column A, copies that
row and the row above it, then pastes it directly under the last occupied row.

Range("A65536").End(xlUp).Select
ActiveCell.Offset(-1, 0).Select
Rows(ActiveCell.Row & ":" & ActiveCell.Offset(1, 0).Row).Copy
ActiveCell.Offset(2, 0).Select
Rows(ActiveCell.Row & ":" & ActiveCell.Offset(1, 0).Row).Select
ActiveSheet.Paste
Application.CutCopyMode = False

Hope this helps, Jim
--
I appreciate any feedback.

Simon[_2_]

Using .Row help please
 
On Aug 5, 4:19*pm, Dave Peterson wrote:
You just want to copy the last 2 rows to the bottom of the range?

Dim RngToCopy as range
dim DestCell as range

with activesheet
* set rngtocopy = .cells(.rows.count,"A").end(xlup).offset(-1,0)
* set destcell = .cells(.rows.count,"A").end(xlup).offset(1,0)
end with

rngtocopy.resize(2,1).entirerow.copy _
* destination:=destcell





Simon wrote:

Each month I add 2 rows from the bottom of the previous month.


To do this I would like some assistance please.


I thought it would encompass


Range [A36636].Select
Selection.End(xlUp).Offset(-1, 0).Row


'then somehow select the bottom two used rows and copy them directly
underneath the copied rows


Thanks for your help. *Unfortunately I have ye tto learn much about
the Row property.


Regards,


Si


--

Dave Peterson- Hide quoted text -

- Show quoted text -


Hi Dave,

It works, you are a genius!

Does the A in cells(.rows.count,"A").end(xlup).offset(-1,0) refer to
column A?

What does Resize(2, 1) do? thanks.

J Sedoff comRemove>

Using .Row help please
 
The numbers in the offset parenthesis are indeed called indexes. They are in
the order (as much of the range-type commands are) of Row Index, Column Index.

(Do you understand what it is doing? I don't mind explaining it, if you
want.)

I hope this works for you, Jim
--
I appreciate any feedback.


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

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