+ Reply to Thread
Results 1 to 3 of 3

Importing Data From another Excel worksheet

  1. #1
    Registered User
    Join Date
    07-22-2009
    Location
    California
    MS-Off Ver
    Microsoft Office 03
    Posts
    2

    Importing Data From another Excel worksheet

    Hi, I'm trying to import data from one worksheet (Results.xls) onto another one (Original Template.xls) so I can manipulate it. The problem is that the data from results.xls varies from day to day so I've written a dynamic macro to copy and paste it.

    This macro is saved under Original Template.xls

    Sub Getting_Data()
    Dim j As Long


    Workbooks.Open Filename:="D:\Summer Project\Results.xls"

    j = 1
    Do While Cells(j, 1) <> Empty
    Cells(j, 1).Select
    Selection.Copy
    Windows("Original Template.xls").Activate
    Cells(j + 1, 1).Select
    ActiveSheet.Paste

    j = j + 1
    Windows("Results.xls").Activate

    Loop

    End sub

    The problem is that this takes a while to do because the computer'll go through one cell at a time to copy and paste.



    I tried to shorthand it by doing this, :

    Range("A1:AJ").Select
    Selection.Copy

    but excel doesn't recognize the J in AJ as a variable and the macro won't compile properly. What is the proper syntax to have a variable in the Range function?


    Thanks Thanks

  2. #2
    Registered User
    Join Date
    12-19-2007
    Posts
    24

    Re: Importing Data From another Excel worksheet

    I don't remember exactly how it works....

    But I think the below will work.

    Range("A1:A" & J).Select

  3. #3
    Registered User
    Join Date
    07-22-2009
    Location
    California
    MS-Off Ver
    Microsoft Office 03
    Posts
    2

    Re: Importing Data From another Excel worksheet

    Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you for the prompt response!

+ Reply to Thread

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