+ Reply to Thread
Results 1 to 8 of 8

Copy between workbooks in Excel 2003 vba

  1. #1
    Forum Contributor
    Join Date
    03-27-2015
    Location
    Hong Kong
    MS-Off Ver
    Excel 2010
    Posts
    141

    Copy between workbooks in Excel 2003 vba

    Hello Experts,

    I have been confused why the following codes cannot work in Excel 2003 :

    Please Login or Register  to view this content.
    Thx in advance.

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Copy between workbooks in Excel 2003 vba

    Try:
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    03-27-2015
    Location
    Hong Kong
    MS-Off Ver
    Excel 2010
    Posts
    141

    Re: Copy between workbooks in Excel 2003 vba

    Sorry, to make it clear of my problem :

    I've a set of codes created in Excel2010 to import/copy from data one workbook1 to another workbook2.
    The codes work fine in Excel2010 but fail in Excel2003 in a number of code lines.

    I've tried to modify some of the codes to suit Excel2003, but still have the last problem as posted previously.

    I now uploaded the file for your checking :

    I cannot sort out why the macro only stuck at the second last line, while this line also appear previously without throwing error.

    Appreciate your further advice.

    Thx !
    Attached Files Attached Files

  4. #4
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Copy between workbooks in Excel 2003 vba

    I cannot test in Excel2003, but according to Microsoft the notation Application.Workbooks(2).Activate should not cause a problem. Try using what "Record Macro" writes as VBA when activating another workbook.

    Try:
    Please Login or Register  to view this content.
    Instead of:
    Please Login or Register  to view this content.

  5. #5
    Forum Contributor
    Join Date
    03-27-2015
    Location
    Hong Kong
    MS-Off Ver
    Excel 2010
    Posts
    141

    Re: Copy between workbooks in Excel 2003 vba

    No way! I've about 10 macros which are required to be modified from Excel2010 to suit Excel2003.
    It is too difficult and time consuming to do the macro recording again in Excel2003, as in fact, all the 10 sets of macros are accomplished partly by recording only - as some codes are inserted after making reference to on-line search result (and cannot be done solely be recording).

    My point is why the whole macro only is stuck at the second last line ( i.e. Sheets("Transactions").Select ), but this line also appear in front and no error was thrown out.

    Very much perplexed !

  6. #6
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Copy between workbooks in Excel 2003 vba

    You have misread what I wrote.
    I did not suggest that you record the macro again . But just use the different style of notation.

    After testing to see if it works, I would use "search and replace" to replace:
    this notation
    "Application.Workbooks(2).Activate"
    with this notation
    "Windows("zMacro-Import (Excel2003).xls").Activate"
    in all your macros - making sure to replace with the correct file name!

    I previously also suggested replacing
    Sheets("Transactions").Select
    with
    Sheets("Transactions").Activate
    Did this also fail?


    Is VBA failing to activate the other workbook or is it failing to find the worksheet?
    When it fails has the correct workbook been activated?
    What error message are you getting? If none that is very odd

  7. #7
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Copy between workbooks in Excel 2003 vba

    some further thoughts:

    Amend both Range("C5") to a cell that contains a value and try inserting these lines:
    Please Login or Register  to view this content.
    just before this line:
    Please Login or Register  to view this content.
    Are both lines of the message box identical?


    Are you sure that Worksheets(2) the correct reference?
    (Will vary if you have some other workbooks open or if workbooks opened in a different sequence)
    Try running this code after the other macro fails. This will give the "current" workbook numbers
    Please Login or Register  to view this content.
    Your original code fails if "2" is not the correct workbook

  8. #8
    Forum Contributor
    Join Date
    03-27-2015
    Location
    Hong Kong
    MS-Off Ver
    Excel 2010
    Posts
    141

    Re: Copy between workbooks in Excel 2003 vba

    I've been trying to find out the clues for the error, including using Recording Macro in Excel 2003, and amending the macro to suit but to no avail.

    1. I do not specify the workbook name because the name can vary. So instead I use Excel's intrinsic notation of giving the first opened workbook as workbook(1), the second as workbook(2).
    2. I've tried changing the codes as you mentioned, but cannot solve anyway.

    I'm a bit frustrated, and now upload the source file (workbook(1)) [to be opened first] and the macro file (workbook(2)) [to be opened next], to see if anyone with Excel 2003 can check where the errors come from.

    [note that the codes run well in Excel 2010 without problem, but because the macros have to suit some PC with Excel 2003]
    Attached Files Attached Files

+ 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. [SOLVED] Vba excel 2003 - copy & paste from 'master copy' workbook to 2 other workbooks
    By AliiShariff in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-24-2012, 12:58 PM
  2. Copy the string from email in outlook 2003 to excel file 2003
    By kate.middleton1 in forum Excel General
    Replies: 0
    Last Post: 04-14-2012, 03:40 AM
  3. Excel 2003 Additional Workbooks
    By compound in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-21-2007, 12:07 PM
  4. Replies: 4
    Last Post: 12-19-2005, 05:20 PM
  5. Excel 2003 cannot copy between workbooks
    By Robert W. in forum Excel General
    Replies: 3
    Last Post: 12-05-2005, 01:25 PM
  6. [SOLVED] Protecting Workbooks in Excel 2003
    By Misha in forum Excel General
    Replies: 1
    Last Post: 06-23-2005, 03:05 AM
  7. opening workbooks in excel 2003
    By fbe in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-22-2005, 08:34 AM
  8. Can't Copy and Paste between Excel 2003 Workbooks
    By wllee in forum Excel General
    Replies: 7
    Last Post: 03-30-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