close

Hello There
Could Someone show me how i can create a macro to copy the activecell from,
I am only working with column 1,but up to row 60 . So if I select quot;a2quot; on
sheet 2 so the macro would need to look at sheet 1 quot;a2quot; and copy the contents
to sheet2 quot;a2quot; or whichever cell I select upto row 60

I hope this makes some sense to you

Many Thanks Allan


Allen

Try

Option Explicit

Sub CopyRows()
If ActiveCell.Row gt; 60 Then Exit Sub
Sheets(quot;sheet1quot;).Rows(ActiveCell.Row amp; quot;:60quot;).Copy
ActiveSheet.Paste
End Sub--
mudraker
------------------------------------------------------------------------
mudraker's Profile: www.excelforum.com/member.php...foamp;userid=2473
View this thread: www.excelforum.com/showthread...hreadid=537994Hello Mudraker

and thanks for the reply.

This works well, but if possible i need it to run activecell by cell, See
this is a bookin sheet, so when a guest books in today and he wants to book
another night in a12. So i select a12 on sheet2 and the form selects a12 on
sheet 1 and copies only the contents of that cell or row. This form will have
31 sheets ,but will only ever look at the sheet before it.

Does this make sense
thanks again Allan

quot;mudrakerquot; wrote:

gt;
gt; Allen
gt;
gt; Try
gt;
gt; Option Explicit
gt;
gt; Sub CopyRows()
gt; If ActiveCell.Row gt; 60 Then Exit Sub
gt; Sheets(quot;sheet1quot;).Rows(ActiveCell.Row amp; quot;:60quot;).Copy
gt; ActiveSheet.Paste
gt; End Sub
gt;
gt;
gt; --
gt; mudraker
gt; ------------------------------------------------------------------------
gt; mudraker's Profile: www.excelforum.com/member.php...foamp;userid=2473
gt; View this thread: www.excelforum.com/showthread...hreadid=537994
gt;
gt;


Allen

I hope I understand correctly what you are after

This macro uses the sheet.index function
I have assumed that you have your sheets in order from left (sheet1) to
right sheet31

Sub CopyRows()
If ActiveSheet.Index =1 Then Exit Sub
If ActiveCell.Row gt; 60 Then Exit Sub
Sheets(ActiveSheet.Index - 1).Rows(ActiveCell.Row).Copy
ActiveSheet.Paste
End Sub

If they are in the reverse order then use

Sub CopyRows()
If ActiveSheet.Index =1 Then Exit Sub
If ActiveCell.Row gt; 60 Then Exit Sub
Sheets(ActiveSheet.Index 1).Rows(ActiveCell.Row).Copy
ActiveSheet.Paste
End Sub--
mudraker
------------------------------------------------------------------------
mudraker's Profile: www.excelforum.com/member.php...foamp;userid=2473
View this thread: www.excelforum.com/showthread...hreadid=537994mudraker

You have hit it on the head, and i am greatful.
thankyou very much

Allan

quot;mudrakerquot; wrote:

gt;
gt; Allen
gt;
gt; I hope I understand correctly what you are after
gt;
gt; This macro uses the sheet.index function
gt; I have assumed that you have your sheets in order from left (sheet1) to
gt; right sheet31
gt;
gt; Sub CopyRows()
gt; If ActiveSheet.Index =1 Then Exit Sub
gt; If ActiveCell.Row gt; 60 Then Exit Sub
gt; Sheets(ActiveSheet.Index - 1).Rows(ActiveCell.Row).Copy
gt; ActiveSheet.Paste
gt; End Sub
gt;
gt; If they are in the reverse order then use
gt;
gt; Sub CopyRows()
gt; If ActiveSheet.Index =1 Then Exit Sub
gt; If ActiveCell.Row gt; 60 Then Exit Sub
gt; Sheets(ActiveSheet.Index 1).Rows(ActiveCell.Row).Copy
gt; ActiveSheet.Paste
gt; End Sub
gt;
gt;
gt; --
gt; mudraker
gt; ------------------------------------------------------------------------
gt; mudraker's Profile: www.excelforum.com/member.php...foamp;userid=2473
gt; View this thread: www.excelforum.com/showthread...hreadid=537994
gt;
gt;

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()