+ Reply to Thread
Results 1 to 4 of 4

Copy/ Destination to different workbook. Trouble with the Syntax

Hybrid View

graym463 Copy/ Destination to... 08-22-2015, 07:07 PM
berlan Re: Copy/ Destination to... 08-22-2015, 07:13 PM
Norie Re: Copy/ Destination to... 08-22-2015, 07:15 PM
graym463 Re: Copy/ Destination to... 08-22-2015, 07:37 PM
  1. #1
    Registered User
    Join Date
    07-16-2015
    Location
    Brighton, England
    MS-Off Ver
    2010
    Posts
    71

    Copy/ Destination to different workbook. Trouble with the Syntax

    Hi thanks for looking.

    Please could you advise me on whats wrong with the setup of the line below? Or if i need to use a different method.

    Its looping through workbooks and im trying to get it to use the last available row.

    Thanks very much

    Selection.Copy Desination:=Workbooks("AllAccounts").Sheet1.Range(Rows.Count, 1).End(xlUp).Offset(1, 0)

  2. #2
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Copy/ Destination to different workbook. Trouble with the Syntax

    Hi,

    I believe you can't use the sheet codename like Thisworkbook.Sheet1 or Workbooks("AllAccounts").Sheet1. Instead use e.g. Thisworkbook.sheets("Sheet1") where "Sheet1" is the sheet name.

    Try,
    Selection.Copy Workbooks("AllAccounts").Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp)(2)
    and change the sheet name (in blue) as needed.

    EDIT: changes needed, including the cell reference.
    Last edited by berlan; 08-22-2015 at 07:21 PM.

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Copy/ Destination to different workbook. Trouble with the Syntax

    Well the first thing is the incorrect spelling of Destination .

    Other than that it's hard to tell without knowing what errors you are getting.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    07-16-2015
    Location
    Brighton, England
    MS-Off Ver
    2010
    Posts
    71

    Re: Copy/ Destination to different workbook. Trouble with the Syntax

    Haha oh dear, I am going VBlind! Thank you both very much, that has corrected the issue!

    final code snippet

        Do While Filename <> ""
    '        If Not wb.Name = XLSFolder & "AllAccounts.xlsx" Then
            Workbooks.Open (XLSFolder & Filename)
        Set rngX = ActiveSheet.Range("A:A").Find("DATE", lookat:=xlPart) ' 1st DATE
        Set OfValue = rngX.Offset(1, 0) 'Finds date address 1 offset first value
            
            OfValue.Offset(1, 5).Select
            Range(Selection, Selection.End(xlToLeft)).Select
            Range(Selection, Selection.End(xlDown)).Offset(-1, 0).Select
            Selection.Copy Destination:=Workbooks("AllAccounts").Sheets("AllAccounts").Range("A" & Rows.Count).End(xlUp)(2)
            ActiveWorkbook.Close False
            Filename = Dir()
        Loop

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Copy Destination Syntax Issue
    By ptmuldoon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-18-2015, 11:26 AM
  2. [SOLVED] Copy Destination Syntax Error
    By jsmilke in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-17-2014, 04:40 PM
  3. Replies: 3
    Last Post: 07-11-2013, 03:01 AM
  4. Copy Destination syntax
    By stevecan in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-31-2012, 08:28 AM
  5. Copy Destination Syntax
    By delirium in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-18-2008, 01:49 PM
  6. [SOLVED] how to copy succeeding rows from source workbook to destination w.
    By chris in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-08-2005, 10:06 AM

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.6.0 RC 1