+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    04-15-2009
    Location
    Israel
    MS-Off Ver
    Excel 2003
    Posts
    69

    Copy and Paste not working

    Hello Experts

    What's wrong with my code - copy table and paste the table and the next valuable row at another documents

    Code:
    ub a_84()
    
    Worksheets("atr 1").Activate
    Range("g12").Activate
    Range("g" & 12 & ":i" & 250).Select
       Selection.Copy
       Workbooks("84.xls").Activate
       Worksheets("Sheet2").Activate
       Range("a1").Select
       Range("a1").End(xlDown).Offset(1, 0).Select
       ActiveSheet.Paste
    End Sub
    Thanks
    Shark Man

  2. #2
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    02-15-2008
    Location
    Grappenhall, UK
    MS-Off Ver
    Excel for Windows & Mac - all versions.
    Posts
    5,826

    Re: Copy and Paste not working

    Hi,

    What isn't it doing that you expect? Also what do you mean by 'paste the table and the next valuable row at another documents'. That's not clear to me.

    As an aside you don't need all those .Select and .Activate instructions. Just address the relevant sheet/range directly.

    Regards
    Richard Buttrey

    If this was useful then please rate it appropriately.

    Click the small star icon at the bottom left of my post.

  3. #3
    Registered User
    Join Date
    04-15-2009
    Location
    Israel
    MS-Off Ver
    Excel 2003
    Posts
    69

    Re: Copy and Paste not working

    Hello Richard

    I want to copy table from one file to another file at the next available row

    Thanks

  4. #4
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    02-15-2008
    Location
    Grappenhall, UK
    MS-Off Ver
    Excel for Windows & Mac - all versions.
    Posts
    5,826

    Re: Copy and Paste not working

    Hi,

    Do you really mean from one file (presumably workbook) to another? Your code is only using one workbook and copying within it.

    Rgds
    Richard Buttrey

    If this was useful then please rate it appropriately.

    Click the small star icon at the bottom left of my post.

  5. #5
    Registered User
    Join Date
    04-15-2009
    Location
    Israel
    MS-Off Ver
    Excel 2003
    Posts
    69

    Re: Copy and Paste not working

    Hay Richard

    Probably that's my problem

    I want to copy from the current file worksheet "atr 1" to another file name "84.xls worksheets "sheet 2"

    Can you help repair my code ?

    Thanks in advanced

  6. #6
    Forum Moderator Richard Buttrey's Avatar
    Join Date
    02-15-2008
    Location
    Grappenhall, UK
    MS-Off Ver
    Excel for Windows & Mac - all versions.
    Posts
    5,826

    Re: Copy and Paste not working

    Hi,

    In which case try:

    Code:
    Sub a_84()
    
    Dim wbMain as Workbook, wbTemp as Workbook
    Set wbMain = ActiveWorkbook
    Workbooks.Open FileName:="a84.xls" 'note add a path string if a84 is not in the default folder
    Set wbTemp=Activeworkbook
    wbMain.Worksheets("atr 1").Range("g12").Copy Destination:= wbTemp.Worksheet("Sheet2").Range("A1").End(xlDown).Offset(1,0)
    
    'then if necessary
    wbTemp.Save
    wbTemp.Close
    End Sub
    HTH
    Richard Buttrey

    If this was useful then please rate it appropriately.

    Click the small star icon at the bottom left of my post.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0