PC Review


Reply
Thread Tools Rate Thread

Copy from ActiveRow, Paste to A2 in Another Sheet

 
 
ryguy7272
Guest
Posts: n/a
 
      6th Oct 2009
I am trying to copy a row (could be any row) from a sheet named ‘Master’ and
paste to another sheet, named ‘Summary’, in the same workbook, and
PasteSpecial in Cell A2.

Below is the code that I'm trying to implement:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Dim Currrow As Range
Currrow = Range("A2" & .Row & ":V" & .Row)
Worksheets("Master").Range("A" & Currrow & ":V" & Currrow).Copy
Worksheets("Summary").Range("A2").PasteSpecial
End Sub

It would be the entire row; doesn't matter. The data goes from A:V.

Thanks,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.
 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      6th Oct 2009
A bit confusing. Do you mean copy a single row (which is the target row) and
is sheet Master the active sheet . Then try the below. Event for master sheet

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Cancel = True
Application.EnableEvents = False
Rows(Target.Row).Copy
Sheets("Summary").Range("A2").PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
'OR to copy with formats
'Rows(Target.Row).Copy Sheets("Summary").Range("A2")
'Application.EnableEvents = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"ryguy7272" wrote:

> I am trying to copy a row (could be any row) from a sheet named ‘Master’ and
> paste to another sheet, named ‘Summary’, in the same workbook, and
> PasteSpecial in Cell A2.
>
> Below is the code that I'm trying to implement:
> Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> Boolean)
> Dim Currrow As Range
> Currrow = Range("A2" & .Row & ":V" & .Row)
> Worksheets("Master").Range("A" & Currrow & ":V" & Currrow).Copy
> Worksheets("Summary").Range("A2").PasteSpecial
> End Sub
>
> It would be the entire row; doesn't matter. The data goes from A:V.
>
> Thanks,
> Ryan---
>
> --
> Ryan---
> If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      6th Oct 2009
If you are looking to copy only the values the below single line would do

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Application.EnableEvents = False
Sheets("Summary").Rows(2) = Rows(Target.Row).Value
Application.EnableEvents = True: Cancel = True
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

> A bit confusing. Do you mean copy a single row (which is the target row) and
> is sheet Master the active sheet . Then try the below. Event for master sheet
>
> Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> Boolean)
> Cancel = True
> Application.EnableEvents = False
> Rows(Target.Row).Copy
> Sheets("Summary").Range("A2").PasteSpecial Paste:=xlValues
> Application.CutCopyMode = False
> 'OR to copy with formats
> 'Rows(Target.Row).Copy Sheets("Summary").Range("A2")
> 'Application.EnableEvents = True
> End Sub
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "ryguy7272" wrote:
>
> > I am trying to copy a row (could be any row) from a sheet named ‘Master’ and
> > paste to another sheet, named ‘Summary’, in the same workbook, and
> > PasteSpecial in Cell A2.
> >
> > Below is the code that I'm trying to implement:
> > Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> > Boolean)
> > Dim Currrow As Range
> > Currrow = Range("A2" & .Row & ":V" & .Row)
> > Worksheets("Master").Range("A" & Currrow & ":V" & Currrow).Copy
> > Worksheets("Summary").Range("A2").PasteSpecial
> > End Sub
> >
> > It would be the entire row; doesn't matter. The data goes from A:V.
> >
> > Thanks,
> > Ryan---
> >
> > --
> > Ryan---
> > If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      6th Oct 2009
Thanks Jacob! I see that you've got the gold now!!

The first macro worked one time, but didn't work any subsequent times. The
Second macro didn't work. Seems to be something preventing it from working.
Is there some way to reset the macro. Also, I tried to clear the contents of
sheet 'Summary' row2, but now I get an error. Must be something with the
event-driven nature of the macro that I don't understand.

Working with this now:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
Sheets("Summary").Select
Rows("2:2").Select ' < -- error occurs here
Selection.ClearContents
Sheets("Master").Select
Cancel = True
Application.EnableEvents = False
Rows(Target.Row).Copy
Sheets("Summary").Range("A2").PasteSpecial Paste:=xlValues
Application.CutCopyMode = False
'OR to copy with formats
'Rows(Target.Row).Copy Sheets("Summary").Range("A2")
'Application.EnableEvents = True
End Sub

This must be an easy fix, right.

Thanks,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Jacob Skaria" wrote:

> If you are looking to copy only the values the below single line would do
>
> Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> Boolean)
> Application.EnableEvents = False
> Sheets("Summary").Rows(2) = Rows(Target.Row).Value
> Application.EnableEvents = True: Cancel = True
> End Sub
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Jacob Skaria" wrote:
>
> > A bit confusing. Do you mean copy a single row (which is the target row) and
> > is sheet Master the active sheet . Then try the below. Event for master sheet
> >
> > Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> > Boolean)
> > Cancel = True
> > Application.EnableEvents = False
> > Rows(Target.Row).Copy
> > Sheets("Summary").Range("A2").PasteSpecial Paste:=xlValues
> > Application.CutCopyMode = False
> > 'OR to copy with formats
> > 'Rows(Target.Row).Copy Sheets("Summary").Range("A2")
> > 'Application.EnableEvents = True
> > End Sub
> >
> > If this post helps click Yes
> > ---------------
> > Jacob Skaria
> >
> >
> > "ryguy7272" wrote:
> >
> > > I am trying to copy a row (could be any row) from a sheet named ‘Master’ and
> > > paste to another sheet, named ‘Summary’, in the same workbook, and
> > > PasteSpecial in Cell A2.
> > >
> > > Below is the code that I'm trying to implement:
> > > Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> > > Boolean)
> > > Dim Currrow As Range
> > > Currrow = Range("A2" & .Row & ":V" & .Row)
> > > Worksheets("Master").Range("A" & Currrow & ":V" & Currrow).Copy
> > > Worksheets("Summary").Range("A2").PasteSpecial
> > > End Sub
> > >
> > > It would be the entire row; doesn't matter. The data goes from A:V.
> > >
> > > Thanks,
> > > Ryan---
> > >
> > > --
> > > Ryan---
> > > If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      6th Oct 2009
Accidently I have marked the last line of the first macro. So unmark that
line. and in your immediate window paste that line and enter so that events
are enabled...Now try all 3 options (2 options mentioned in the 1st post)

Application.EnableEvents = True


If this post helps click Yes
---------------
Jacob Skaria


"ryguy7272" wrote:

> Thanks Jacob! I see that you've got the gold now!!
>
> The first macro worked one time, but didn't work any subsequent times. The
> Second macro didn't work. Seems to be something preventing it from working.
> Is there some way to reset the macro. Also, I tried to clear the contents of
> sheet 'Summary' row2, but now I get an error. Must be something with the
> event-driven nature of the macro that I don't understand.
>
> Working with this now:
> Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> Boolean)
> Sheets("Summary").Select
> Rows("2:2").Select ' < -- error occurs here
> Selection.ClearContents
> Sheets("Master").Select
> Cancel = True
> Application.EnableEvents = False
> Rows(Target.Row).Copy
> Sheets("Summary").Range("A2").PasteSpecial Paste:=xlValues
> Application.CutCopyMode = False
> 'OR to copy with formats
> 'Rows(Target.Row).Copy Sheets("Summary").Range("A2")
> 'Application.EnableEvents = True
> End Sub
>
> This must be an easy fix, right.
>
> Thanks,
> Ryan---
>
> --
> Ryan---
> If this information was helpful, please indicate this by clicking ''Yes''.
>
>
> "Jacob Skaria" wrote:
>
> > If you are looking to copy only the values the below single line would do
> >
> > Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> > Boolean)
> > Application.EnableEvents = False
> > Sheets("Summary").Rows(2) = Rows(Target.Row).Value
> > Application.EnableEvents = True: Cancel = True
> > End Sub
> >
> > If this post helps click Yes
> > ---------------
> > Jacob Skaria
> >
> >
> > "Jacob Skaria" wrote:
> >
> > > A bit confusing. Do you mean copy a single row (which is the target row) and
> > > is sheet Master the active sheet . Then try the below. Event for master sheet
> > >
> > > Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> > > Boolean)
> > > Cancel = True
> > > Application.EnableEvents = False
> > > Rows(Target.Row).Copy
> > > Sheets("Summary").Range("A2").PasteSpecial Paste:=xlValues
> > > Application.CutCopyMode = False
> > > 'OR to copy with formats
> > > 'Rows(Target.Row).Copy Sheets("Summary").Range("A2")
> > > 'Application.EnableEvents = True
> > > End Sub
> > >
> > > If this post helps click Yes
> > > ---------------
> > > Jacob Skaria
> > >
> > >
> > > "ryguy7272" wrote:
> > >
> > > > I am trying to copy a row (could be any row) from a sheet named ‘Master’ and
> > > > paste to another sheet, named ‘Summary’, in the same workbook, and
> > > > PasteSpecial in Cell A2.
> > > >
> > > > Below is the code that I'm trying to implement:
> > > > Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> > > > Boolean)
> > > > Dim Currrow As Range
> > > > Currrow = Range("A2" & .Row & ":V" & .Row)
> > > > Worksheets("Master").Range("A" & Currrow & ":V" & Currrow).Copy
> > > > Worksheets("Summary").Range("A2").PasteSpecial
> > > > End Sub
> > > >
> > > > It would be the entire row; doesn't matter. The data goes from A:V.
> > > >
> > > > Thanks,
> > > > Ryan---
> > > >
> > > > --
> > > > Ryan---
> > > > If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
ryguy7272
Guest
Posts: n/a
 
      6th Oct 2009
Ah! Yes! Clearly that works! I'm very tired today...
Thanks Jacob,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"Jacob Skaria" wrote:

> Accidently I have marked the last line of the first macro. So unmark that
> line. and in your immediate window paste that line and enter so that events
> are enabled...Now try all 3 options (2 options mentioned in the 1st post)
>
> Application.EnableEvents = True
>
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "ryguy7272" wrote:
>
> > Thanks Jacob! I see that you've got the gold now!!
> >
> > The first macro worked one time, but didn't work any subsequent times. The
> > Second macro didn't work. Seems to be something preventing it from working.
> > Is there some way to reset the macro. Also, I tried to clear the contents of
> > sheet 'Summary' row2, but now I get an error. Must be something with the
> > event-driven nature of the macro that I don't understand.
> >
> > Working with this now:
> > Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> > Boolean)
> > Sheets("Summary").Select
> > Rows("2:2").Select ' < -- error occurs here
> > Selection.ClearContents
> > Sheets("Master").Select
> > Cancel = True
> > Application.EnableEvents = False
> > Rows(Target.Row).Copy
> > Sheets("Summary").Range("A2").PasteSpecial Paste:=xlValues
> > Application.CutCopyMode = False
> > 'OR to copy with formats
> > 'Rows(Target.Row).Copy Sheets("Summary").Range("A2")
> > 'Application.EnableEvents = True
> > End Sub
> >
> > This must be an easy fix, right.
> >
> > Thanks,
> > Ryan---
> >
> > --
> > Ryan---
> > If this information was helpful, please indicate this by clicking ''Yes''.
> >
> >
> > "Jacob Skaria" wrote:
> >
> > > If you are looking to copy only the values the below single line would do
> > >
> > > Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> > > Boolean)
> > > Application.EnableEvents = False
> > > Sheets("Summary").Rows(2) = Rows(Target.Row).Value
> > > Application.EnableEvents = True: Cancel = True
> > > End Sub
> > >
> > > If this post helps click Yes
> > > ---------------
> > > Jacob Skaria
> > >
> > >
> > > "Jacob Skaria" wrote:
> > >
> > > > A bit confusing. Do you mean copy a single row (which is the target row) and
> > > > is sheet Master the active sheet . Then try the below. Event for master sheet
> > > >
> > > > Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> > > > Boolean)
> > > > Cancel = True
> > > > Application.EnableEvents = False
> > > > Rows(Target.Row).Copy
> > > > Sheets("Summary").Range("A2").PasteSpecial Paste:=xlValues
> > > > Application.CutCopyMode = False
> > > > 'OR to copy with formats
> > > > 'Rows(Target.Row).Copy Sheets("Summary").Range("A2")
> > > > 'Application.EnableEvents = True
> > > > End Sub
> > > >
> > > > If this post helps click Yes
> > > > ---------------
> > > > Jacob Skaria
> > > >
> > > >
> > > > "ryguy7272" wrote:
> > > >
> > > > > I am trying to copy a row (could be any row) from a sheet named ‘Master’ and
> > > > > paste to another sheet, named ‘Summary’, in the same workbook, and
> > > > > PasteSpecial in Cell A2.
> > > > >
> > > > > Below is the code that I'm trying to implement:
> > > > > Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
> > > > > Boolean)
> > > > > Dim Currrow As Range
> > > > > Currrow = Range("A2" & .Row & ":V" & .Row)
> > > > > Worksheets("Master").Range("A" & Currrow & ":V" & Currrow).Copy
> > > > > Worksheets("Summary").Range("A2").PasteSpecial
> > > > > End Sub
> > > > >
> > > > > It would be the entire row; doesn't matter. The data goes from A:V.
> > > > >
> > > > > Thanks,
> > > > > Ryan---
> > > > >
> > > > > --
> > > > > Ryan---
> > > > > If this information was helpful, please indicate this by clicking ''Yes''.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Paste from Class Sheet to Filtered List on Combined Sheet prkhan56@gmail.com Microsoft Excel Programming 6 16th Sep 2008 04:30 PM
Help to code Macro to Copy fron one sheet and paste in other sheet kay Microsoft Excel Programming 3 25th Jul 2008 06:46 PM
Copy from one Sheet and paste on another sheet based on condition Prem Microsoft Excel Misc 2 24th Dec 2007 05:05 AM
Active Cell Copy And Paste Sheet to Sheet =?Utf-8?B?QS5SLkogQWxsYW4gSmVmZmVyeXM=?= Microsoft Excel New Users 4 4th May 2006 02:04 AM
automatic copy and paste from sheet to sheet in a workbook =?Utf-8?B?cmFtc2V5anJhbXNleWo=?= Microsoft Excel Programming 6 11th Dec 2004 12:37 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:06 AM.