PC Review


Reply
Thread Tools Rate Thread

Copy Patse Macro

 
 
Len
Guest
Posts: n/a
 
      20th Jun 2008
Hi,

I begin to learn to set a macro for the following codes where the data
from the table in an excel worksheet ( ie the range could be from A1
to H50 or A1 to K245 depending the data file ) exclude hidden rows,
is copied to a cell below 5 rows of the above table : -

Range("A1").End(xlDown).Select
Selection.CurrentRegion.Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Sheets("Exp_Grp").Select
Range("A1").End(XlDown).Offset(5,0).Select
ActiveSheet.Paste
Application.CutCopyMode = False

When I execute this macro, it prompts an error message
Please help to rectify the above codes, thanks

Regards
Len

 
Reply With Quote
 
 
 
 
Len
Guest
Posts: n/a
 
      20th Jun 2008
On Jun 20, 3:34*pm, "Snake Plissken" <vico11wywal...@poczta.onet.pl>
wrote:
> like this, maybe?
>
> * * Sheets("Exp_Grp").Select
> * * Range("A1").End(xlDown).Select
> * * ActiveCell.Offset(5, 0).Select
> * * ActiveSheet.Paste
> * * Application.CutCopyMode = False


Hi,

Thanks for prompt reply.
After rectifying the codes based on your suggestion, it still turns
out the same error message at ActiveSheet.Paste ??

Regards
Len
 
Reply With Quote
 
Len
Guest
Posts: n/a
 
      20th Jun 2008
On Jun 20, 4:00*pm, "Snake Plissken" <vico11wywal...@poczta.onet.pl>
wrote:
> What kind of message? Please specify.


Hi,

The error message " Run Time error '1004', This selection is not
valid. There are several possible reasons : -
a) Copy & paste areas cannot overlap unless they're the same size and
shape
b) If you're using the Create command on the Name submenu of the
Insert menu, the row or column containing the proposed names won't.....
( not enough space to show the remaining text )

Note : macro run on excel'2000 and the table that copy over is after
running subtotal functions

Regards
Len
 
Reply With Quote
 
Len
Guest
Posts: n/a
 
      20th Jun 2008
On Jun 20, 5:13*pm, "Snake Plissken" <vico11wywal...@poczta.onet.pl>
wrote:
> It seems that the destination sheet must have at least 2 rows of data.
> Otherwise macro tries to select the very bottom of the sheets and them paste
> data below it *- which is of course impossible
> Run macro step by step (F8) then you'll see what's going on
>
> I have changed the code to omit the problem somehow but it can be done ina
> a better wa I suppose
>
> Sub test()
> 'it should be run from source sheet
>
> * * Range("A1").End(xlDown).Select
> * * Selection.CurrentRegion.Select
> * * Selection.SpecialCells(xlCellTypeVisible).Select
> * * Selection.Copy
> * * Sheets("Exp_Grp").Select
> * * Range("A1").End(xlDown).Select
> * * Selection.CurrentRegion.Select
> * * If Selection.Rows.Count > 1 Then
> * * * * Range("A1").End(xlDown).Select
> * * * * ActiveCell.Offset(5, 0).Select
> * * * * ActiveSheet.Paste
> * * Else
> * * * * Range("A1").Select
> * * * * ActiveCell.Offset(5, 0).Select
> * * * * ActiveSheet.Paste
>
> * * End If
>
> * * Application.CutCopyMode = False
>
> End Sub


Hi

Based on your new codes and run F8 step by step going thro the macro,
the same error message prompts at ActiveSheet.Paste and it stops

It seems that the selected range from A3 to O97 ( ie row
3,22,26,29,33,39,45,47,49,55,57,59,61,97 ) is unable to copy over and
it hangs at that worksheet

Regards
Len



 
Reply With Quote
 
Len
Guest
Posts: n/a
 
      20th Jun 2008
On Jun 20, 7:47*pm, Len <ltong2000...@yahoo.co.uk> wrote:
> On Jun 20, 5:13*pm, "Snake Plissken" <vico11wywal...@poczta.onet.pl>
> wrote:
>
>
>
>
>
> > It seems that the destination sheet must have at least 2 rows of data.
> > Otherwise macro tries to select the very bottom of the sheets and them paste
> > data below it *- which is of course impossible
> > Run macro step by step (F8) then you'll see what's going on

>
> > I have changed the code to omit the problem somehow but it can be done in a
> > a better wa I suppose

>
> > Sub test()
> > 'it should be run from source sheet

>
> > * * Range("A1").End(xlDown).Select
> > * * Selection.CurrentRegion.Select
> > * * Selection.SpecialCells(xlCellTypeVisible).Select
> > * * Selection.Copy
> > * * Sheets("Exp_Grp").Select
> > * * Range("A1").End(xlDown).Select
> > * * Selection.CurrentRegion.Select
> > * * If Selection.Rows.Count > 1 Then
> > * * * * Range("A1").End(xlDown).Select
> > * * * * ActiveCell.Offset(5, 0).Select
> > * * * * ActiveSheet.Paste
> > * * Else
> > * * * * Range("A1").Select
> > * * * * ActiveCell.Offset(5, 0).Select
> > * * * * ActiveSheet.Paste

>
> > * * End If

>
> > * * Application.CutCopyMode = False

>
> > End Sub

>
> Hi
>
> Based on your new codes and run F8 step by step going thro the macro,
> the same error message prompts at ActiveSheet.Paste and it stops
>
> It seems that the selected range from A3 to O97 ( ie row
> 3,22,26,29,33,39,45,47,49,55,57,59,61,97 ) is unable to copy over and
> it hangs at that worksheet
>
> Regards
> Len- Hide quoted text -
>
> - Show quoted text -


One more thing, the macro copies the selected range from A3 to O97 and
move to cell A3 and it stops when it hit the code "
Range("A1").End(xlDown).Select and ActiveCell.Offset(5, 0).Select"


 
Reply With Quote
 
Len
Guest
Posts: n/a
 
      24th Jun 2008
On Jun 20, 8:25*pm, "Snake Plissken" <vico11wywal...@poczta.onet.pl>
wrote:
> I'll look on that next week but it works with sample data I put. Strange....


Hi Snake,

After exploring more scenarios, I discovered copy/paste VBA based on
the following modified codes, is workable in 1st scenario ( ie where
copy range starts from A1:A1103 of which filtered cells are from
A2:A1103) and not workable in 2nd scenario ( ie where copy range
starts from A3:A97 of which filtered cells are from A22:A1103 and
cells A1 to A3 are not filtered) where it stops at cell A3 after it
hits the code " ActiveSheet.Paste "

Sub Copy_Paste()

Sheets("GL-LG").Select
Range("A1").End(xlDown).Select
Selection.CurrentRegion.Select
Selection.SpecialCells(xlCellTypeVisible).Select
Selection.Copy
Range("A1").End(xlDown).Select
ActiveCell.Offset(10, 0).Select
ActiveSheet.Paste
Application.CutCopyMode = False

End Sub

Any idea on the above problem ?, thanks


Regards
Len

 
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
Macro to copy and paste values (columns)I have a macro file built C02C04 Microsoft Excel Programming 2 2nd May 2008 01:51 PM
Copying and Patse =?Utf-8?B?c2h1bg==?= Microsoft Excel Misc 2 9th Feb 2006 10:57 PM
Patse Rows from one Sheet to another with a Twist John Microsoft Excel Programming 18 8th Aug 2005 06:57 AM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Microsoft Excel Programming 1 15th Oct 2004 01:16 PM
Right Mouse Click does not give me cut/patse menu in advanced find Phillips Microsoft Outlook 2 25th Nov 2003 07:18 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:14 AM.