Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default 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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,124
Default 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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default 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.
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 89
Default 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.


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default 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.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"